:root {
  --bg: #f6f4ef;
  --surface: #fffdf8;
  --ink: #17211b;
  --muted: #5c6b60;
  --brand: #0f8a5f;
  --brand-strong: #0c6d4a;
  --error: #b42318;
  --ring: rgba(15, 138, 95, 0.22);
  --border: #d6d9cf;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'PingFang SC', 'Noto Sans SC', 'Microsoft YaHei', sans-serif;
  color: var(--ink);
  min-height: 100vh;
  background:
    radial-gradient(circle at 0% 0%, #e9f9f3 0, transparent 28%),
    radial-gradient(circle at 100% 100%, #f8eede 0, transparent 30%),
    var(--bg);
}

.page {
  max-width: 780px;
  margin: 0 auto;
  padding: 28px 16px 40px;
}

.page--center {
  display: flex;
  align-items: center;
  min-height: 100vh;
}

.card {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 10px 35px rgba(20, 33, 27, 0.08);
}

.card--wide {
  margin-top: 12px;
}

h1 {
  margin: 0 0 8px;
  font-size: 24px;
}

.subtle {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 14px;
}

label,
legend {
  font-weight: 600;
  font-size: 14px;
}

.field {
  margin-bottom: 14px;
}

input,
textarea,
button {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  font: inherit;
}

input,
textarea {
  margin-top: 8px;
  padding: 10px 12px;
  background: #fff;
}

select {
  width: 100%;
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font: inherit;
  background: #fff;
}

.field--timestamp {
  overflow: visible;
  min-width: 0;
}

input[type='datetime-local'] {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  /* Avoid iOS Safari auto-zoom on focus. */
  font-size: 16px;
}

.field--timestamp input[type='time'] {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin-top: 8px;
  min-height: 44px;
  padding-inline: 12px;
  overflow: hidden;
  text-align: left;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* Force iOS/WebKit time value to align left instead of centered. */
.field--timestamp input[type='time']::-webkit-date-and-time-value {
  width: 100%;
  box-sizing: border-box;
  text-align: left;
}

.field--timestamp input[type='time']::-webkit-date-and-time-value,
.field--timestamp input[type='time']::-webkit-datetime-edit {
  min-height: 1.2em;
}

.date-quick {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.date-chip {
  width: auto;
  margin: 0;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid #c8d8cf;
  background: #f1f7f4;
  color: #265d46;
  font-size: 13px;
  font-weight: 600;
}

.date-chip:hover {
  background: #e5f2ec;
}

.date-chip.is-active {
  border-color: #108659;
  background: #daf1e6;
  color: #0f6e4a;
}

.date-details {
  margin-top: 8px;
}

.date-details summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
}

.date-details input[type='date'] {
  margin-top: 8px;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--ring);
}

button {
  margin-top: 8px;
  padding: 10px 14px;
  background: var(--brand);
  color: #fff;
  border: 0;
  font-weight: 700;
}

button:hover {
  background: var(--brand-strong);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.batch-link {
  display: inline-block;
  margin-top: 10px;
  color: #0a63c6;
  text-decoration: none;
  font-size: 14px;
}

.batch-link:hover {
  text-decoration: underline;
}

.secondary {
  background: #f2f4ef;
  color: var(--ink);
  border: 2px solid transparent;
  background:
    linear-gradient(#f2f4ef, #f2f4ef) padding-box,
    conic-gradient(from -90deg, #d6d9cf 0%, #d6d9cf 100%) border-box;
  --voice-level: 0;
}

.voice-actions {
  margin-top: 8px;
}

.secondary--tiny {
  padding: 6px 10px;
  font-size: 12px;
  margin-top: 0;
}
.secondary:hover {
  background: #e8ebe4;
}

.secondary.is-recording {
  background: #fff3ed;
  color: #9f2600;
  background:
    linear-gradient(#fff3ed, #fff3ed) padding-box,
    conic-gradient(
      from -90deg,
      #17a873 0%,
      #f2b544 calc(var(--voice-level) * 0.6%),
      #e03f2f calc(var(--voice-level) * 1%),
      #d6d9cf calc(var(--voice-level) * 1%),
      #d6d9cf 100%
    ) border-box;
  box-shadow: 0 0 0 2px rgba(224, 63, 47, 0.12);
}

.secondary.is-uploading {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #eef3ff;
  color: #1e429f;
  border-color: #9bb5ef;
  box-shadow: 0 0 0 2px rgba(30, 66, 159, 0.12);
}

.secondary.is-uploading::after {
  content: '';
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid rgba(30, 66, 159, 0.2);
  border-top-color: #1e429f;
  animation: spin-loading 0.8s linear infinite;
}

.secondary.is-uploading:hover {
  background: #eef3ff;
}

@keyframes spin-loading {
  to {
    transform: rotate(360deg);
  }
}

.hint {
  margin: 8px 0 0;
  font-size: 14px;
}

.hint--ok {
  color: var(--brand-strong);
}

.hint--error {
  color: var(--error);
}

.submit-success {
  margin-top: 12px;
  padding: 14px;
  border: 1px solid #bfddcb;
  border-radius: 12px;
  background: #f4fbf7;
}

.submit-success h2 {
  margin: 0 0 8px;
  font-size: 20px;
  color: #0c6d4a;
}

.qr-wrap {
  margin-top: 14px;
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  text-align: center;
}

.qr-wrap img {
  max-width: 220px;
  width: 100%;
  height: auto;
}

.qr-wrap a {
  display: inline-block;
  margin-top: 10px;
  color: #0861c2;
  word-break: break-all;
}

.hidden {
  display: none;
}

.tags {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
}

.tag-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 6px 10px 6px 0;
  padding: 6px 10px;
  border-radius: 999px;
  background: #f1f7f4;
  border: 1px solid #cddfd6;
}

.tag-item input {
  width: auto;
  margin: 0;
}

.action-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.toggle-item {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.toggle-item input {
  width: auto;
  margin: 0;
}

.limit-item {
  margin-top: 6px;
}

.result-wrap {
  margin-top: 16px;
}

.progress-wrap {
  margin-top: 14px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f9fcfa;
}

.progress-meta {
  font-size: 13px;
  color: var(--ink);
  margin-bottom: 8px;
}

.progress-bar {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: #e2ebe5;
  overflow: hidden;
}

.progress-bar__fill {
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #0f8a5f, #25b982);
  transition: width 0.25s ease;
}

.progress-sub {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

.preview-wrap {
  margin-top: 16px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fcfdfb;
}

.preview-wrap h2 {
  margin: 0 0 8px;
  font-size: 16px;
}

.preview-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.preview-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.vin-list {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  max-height: 320px;
  overflow: auto;
}

.vin-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid #eef1ea;
}

.vin-item:last-child {
  border-bottom: 0;
}

.vin-item__vin {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  font-size: 13px;
  color: var(--ink);
}

.vin-item__btn {
  width: auto;
  margin: 0;
  padding: 6px 10px;
  font-size: 12px;
}

.vin-list-empty {
  padding: 12px;
  color: var(--muted);
  font-size: 13px;
}

.result-wrap h2 {
  margin: 0 0 8px;
  font-size: 16px;
}

.result-wrap pre {
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fcfdfb;
  padding: 10px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  line-height: 1.5;
  max-height: 360px;
  overflow: auto;
}

@media (max-width: 640px) {
  .page {
    padding: 14px 12px 24px;
  }

  .card {
    padding: 14px;
    border-radius: 12px;
  }

  h1 {
    font-size: 20px;
  }
}
