:root {
  color-scheme: light;
  --bg: #f7f1e7;
  --bg-accent: #efe2c8;
  --card: rgba(255, 252, 246, 0.92);
  --text: #1f1a17;
  --muted: #6d625a;
  --line: rgba(77, 57, 41, 0.14);
  --primary: #1f6c5a;
  --primary-pressed: #185446;
  --secondary: #fff8ef;
  --error-bg: #fbe7e3;
  --error-text: #8d2f21;
  --success-bg: #e4f3eb;
  --success-text: #1e654d;
  --shadow: 0 24px 60px rgba(80, 53, 21, 0.12);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.6), transparent 32%),
    linear-gradient(180deg, var(--bg-accent), var(--bg));
  color: var(--text);
}

body:not([data-ready="true"]) .app-shell {
  visibility: hidden;
}

body,
input,
button,
textarea,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px 0;
  flex: 1;
}

.card {
  width: min(100%, 28rem);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  padding: 24px;
}

.auth-shell {
  width: min(100%, 66rem);
  display: grid;
  gap: 16px;
  padding-top: 52px;
}

.auth-shell .card {
  width: 100%;
}

.eyebrow {
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  margin-top: 8px;
  font-size: clamp(2rem, 6vw, 2.5rem);
  line-height: 1;
}

h2 {
  font-size: 1.15rem;
}

.supporting-text {
  margin-top: 12px;
  color: var(--muted);
  line-height: 1.5;
}

form {
  margin-top: 24px;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 0.95rem;
}

input,
textarea,
select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.85);
  color: var(--text);
  padding: 15px 16px;
  font-size: 16px;
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible,
button:focus-visible {
  outline: 3px solid rgba(31, 108, 90, 0.22);
  outline-offset: 2px;
}

textarea {
  resize: vertical;
  min-height: 11rem;
  line-height: 1.5;
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 22px) calc(50% - 2px),
    calc(100% - 16px) calc(50% - 2px);
  background-size: 6px 6px;
  background-repeat: no-repeat;
  padding-right: 44px;
}

.button {
  width: 100%;
  border: 0;
  border-radius: 999px;
  padding: 14px 18px;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 120ms ease,
    background-color 120ms ease,
    opacity 120ms ease;
}

.button:active {
  transform: scale(0.99);
}

.button[disabled] {
  cursor: progress;
  opacity: 0.7;
}

.primary {
  background: var(--primary);
  color: #fffdf8;
}

.primary:hover {
  background: var(--primary-pressed);
}

.secondary {
  width: auto;
  background: var(--secondary);
  color: var(--text);
  border: 1px solid var(--line);
}

.message {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: 14px;
  line-height: 1.45;
}

.error {
  background: var(--error-bg);
  color: var(--error-text);
}

.success {
  background: var(--success-bg);
  color: var(--success-text);
}

.capture-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.shell-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: max(6px, env(safe-area-inset-top)) 16px 6px;
  background: rgba(255, 252, 246, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
  width: 100%;
}

.shell-header .eyebrow,
.shell-header .shell-copy {
  display: none;
}

.shell-copy {
  margin-top: 6px;
}

.app-nav {
  display: inline-flex;
  gap: 8px;
}

.nav-button {
  width: auto;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 8px 16px;
  font-size: 0.88rem;
}

.nav-button[aria-current="page"] {
  background: var(--primary);
  border-color: var(--primary);
  color: #fffdf8;
}

.logout-button {
  width: auto;
  padding: 8px 14px;
  font-size: 0.85rem;
}

.capture-card form {
  margin-top: 20px;
}

.capture-card {
  max-width: 34rem;
  justify-self: center;
}

.field-error {
  margin: -8px 0 16px;
  color: var(--error-text);
  font-size: 0.92rem;
  line-height: 1.4;
}

.category-fieldset {
  border: 0;
  margin: 0 0 16px;
  padding: 0;
}

.field-legend {
  color: var(--muted);
  font-size: 0.95rem;
  margin-bottom: 8px;
}

.category-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.category-chip {
  width: auto;
  padding: 8px 14px;
  font-size: 0.88rem;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  border: 1px solid var(--line);
}

.category-chip[aria-pressed="true"] {
  background: rgba(31, 108, 90, 0.12);
  border-color: rgba(31, 108, 90, 0.22);
  color: var(--primary);
}

.category-custom-input {
  border-radius: 16px;
}

.capture-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
  gap: 12px;
  align-items: stretch;
}

.voice-button-shell {
  width: 100%;
}

.voice-button-shell .button {
  height: 100%;
}

.voice-button-shell[data-disabled="true"] .button {
  cursor: not-allowed;
  opacity: 0.72;
}

.voice-button-shell[data-disabled="true"] .button:active {
  transform: none;
}

.noscript-banner {
  position: fixed;
  inset: auto 16px 16px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--error-bg);
  color: var(--error-text);
}

.app-footer {
  position: sticky;
  bottom: 0;
  text-align: center;
  padding: 12px 12px max(12px, env(safe-area-inset-bottom));
  font-size: 0.85rem;
  font-weight: 600;
  font-family: monospace;
  color: var(--muted);
  letter-spacing: 0.05em;
  background: var(--bg);
}

.hidden {
  display: none;
}

@media (max-width: 640px) {
  .app-shell {
    align-items: stretch;
    padding-top: max(8px, env(safe-area-inset-top));
  }

  .card {
    width: 100%;
    border-radius: 22px;
    padding: 22px 18px;
  }

  .auth-shell {
    gap: 10px;
  }

  .capture-header {
    flex-direction: column;
    align-items: stretch;
  }

  .capture-actions {
    grid-template-columns: 1fr;
  }

  .secondary {
    width: 100%;
  }
}
