:root {
  color-scheme: light;
  --bg: #f6f6f3;
  --bg-soft: #ebece8;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-strong: #ffffff;
  --surface-muted: #f1f2ef;
  --line: rgba(25, 29, 34, 0.10);
  --text: #15171a;
  --muted: #6e747c;
  --faint: #9aa0a8;
  --accent: #7bdcc7;
  --accent-text: #07382f;
  --accent-soft: rgba(123, 220, 199, 0.18);
  --danger: #b55243;
  --danger-soft: rgba(181, 82, 67, 0.12);
  --shadow: 0 18px 54px rgba(21, 26, 32, 0.10);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #080b10;
  --bg-soft: #101720;
  --surface: rgba(22, 27, 36, 0.82);
  --surface-strong: #171e28;
  --surface-muted: #202833;
  --line: rgba(255, 255, 255, 0.11);
  --text: #f6f7f8;
  --muted: #a4acb7;
  --faint: #727d8b;
  --accent: #7de2cc;
  --accent-text: #07110e;
  --accent-soft: rgba(125, 226, 204, 0.14);
  --danger: #ff9d8d;
  --danger-soft: rgba(255, 157, 141, 0.12);
  --shadow: 0 24px 76px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  font-weight: 400;
  background:
    radial-gradient(circle at 18% 0%, rgba(123, 220, 199, 0.18), transparent 270px),
    linear-gradient(180deg, var(--bg), var(--bg-soft));
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: 0.46;
}

.app-shell {
  width: min(720px, 100%);
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 14px max(28px, env(safe-area-inset-bottom));
}

.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  min-height: 62px;
  padding: 2px 0 14px;
}

.title-block {
  min-width: 0;
}

.eyebrow,
h1,
h2,
p {
  margin: 0;
}

.eyebrow {
  color: var(--muted);
  font-size: 13px;
  font-weight: 450;
  letter-spacing: 0;
}

h1 {
  margin-top: 2px;
  overflow: hidden;
  font-size: 35px;
  font-weight: 330;
  line-height: 1.05;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

h2 {
  font-size: 22px;
  font-weight: 520;
  line-height: 1.18;
  letter-spacing: 0;
}

.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.icon-button,
.theme-toggle,
.new-button,
.mode-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 10px 28px rgba(21, 26, 32, 0.08);
}

.icon-button,
.new-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  font-size: 27px;
  font-weight: 320;
  line-height: 1;
}

.new-button {
  border-color: transparent;
  background: var(--accent);
  color: var(--accent-text);
}

.theme-toggle,
.mode-pill {
  min-height: 42px;
  padding: 0 15px;
  font-size: 14px;
  font-weight: 520;
}

.view {
  display: grid;
  gap: 12px;
}

.hero-card,
.home-card,
.sheet-dialog form {
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.hero-card {
  min-height: 150px;
  border-radius: 8px;
  padding: 20px;
}

.hero-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 450;
}

.hero-card h2 {
  margin-top: 12px;
  font-size: 30px;
  font-weight: 360;
  letter-spacing: 0;
}

.hero-card p:last-child {
  margin-top: 8px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.42;
}

.home-grid {
  display: grid;
  gap: 10px;
}

.home-card {
  width: 100%;
  min-height: 94px;
  border-radius: 8px;
  padding: 16px;
  color: var(--text);
  text-align: left;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.home-card:active,
.mode-card:active,
.primary-action:active,
.icon-button:active,
.new-button:active {
  transform: scale(0.985);
}

.home-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.home-card-top span {
  font-size: 20px;
  font-weight: 520;
}

.home-card-top strong {
  font-size: 31px;
  font-weight: 340;
  line-height: 1;
}

.home-card small {
  display: block;
  margin-top: 10px;
  overflow: hidden;
  color: var(--muted);
  font-size: 14px;
  font-weight: 390;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quiet-card {
  box-shadow: none;
}

.list-toolbar {
  display: flex;
  justify-content: flex-end;
  padding-bottom: 2px;
}

.mode-pill[aria-pressed="true"] {
  border-color: transparent;
  background: var(--accent);
  color: var(--accent-text);
}

.list-root {
  display: grid;
  gap: 6px;
}

.quick-add-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 4px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-strong) 92%, transparent);
  box-shadow: 0 12px 34px rgba(21, 26, 32, 0.08);
}

.quick-add-input {
  min-width: 0;
  height: 38px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  padding: 0 6px 0 12px;
  outline: none;
}

.quick-add-input::placeholder {
  color: var(--faint);
}

.quick-add-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 25px;
  font-weight: 300;
  line-height: 1;
  touch-action: manipulation;
  transition: opacity 120ms ease, transform 120ms ease;
}

.list-section-label {
  padding: 10px 4px 2px;
  color: var(--faint);
  font-size: 12px;
  font-weight: 520;
  letter-spacing: 0;
}

.list-row {
  appearance: none;
  -webkit-appearance: none;
  -webkit-tap-highlight-color: transparent;
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface-strong) 90%, transparent);
  color: var(--text);
  touch-action: manipulation;
  transition: opacity 150ms ease, transform 150ms ease, border-color 150ms ease, background 150ms ease;
  user-select: none;
}

.list-row:focus,
.list-row:focus-visible {
  outline: none;
}

.shopping-row,
.todo-row {
  display: grid;
  gap: 10px;
  align-items: center;
  text-align: left;
}

.shopping-row {
  grid-template-columns: minmax(0, 1fr) auto;
  min-height: 42px;
  padding: 0;
}

.shopping-row:focus,
.shopping-row:focus-visible {
  outline: none;
}

.shopping-toggle {
  display: grid;
  min-height: 42px;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 9px 12px;
  text-align: left;
}

.shopping-toggle:focus,
.shopping-toggle:focus-visible {
  outline: none;
}

.trash-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 0;
  background: transparent;
  color: var(--muted);
  opacity: 0.86;
}

.trash-button svg {
  width: 19px;
  height: 19px;
  fill: currentColor;
}

.todo-row {
  grid-template-columns: auto minmax(0, 1fr);
  padding: 8px 11px;
}

.todo-row {
  min-height: 58px;
}

.todo-row.is-reorderable {
  cursor: grab;
  touch-action: none;
  -webkit-touch-callout: none;
}

.todo-row.is-lifted-source {
  height: 0;
  min-height: 0;
  border-width: 0;
  padding-top: 0;
  padding-bottom: 0;
  overflow: hidden;
  opacity: 0;
  transform: scale(0.985);
}

.todo-drag-ghost {
  position: fixed;
  z-index: 1000;
  margin: 0;
  pointer-events: none;
  border-color: color-mix(in srgb, var(--accent) 54%, var(--line));
  background: color-mix(in srgb, var(--surface-strong) 96%, var(--accent-soft));
  box-shadow: 0 22px 56px rgba(21, 26, 32, 0.24);
  opacity: 0.98;
  transform: scale(1.028);
  transition: box-shadow 150ms ease, opacity 150ms ease, transform 150ms ease;
  will-change: top, transform;
}

.todo-drag-ghost.is-dropping {
  opacity: 0.9;
  transform: scale(1);
  transition: top 170ms cubic-bezier(0.2, 0.8, 0.2, 1), opacity 170ms ease, transform 170ms ease;
}

.todo-drop-indicator {
  height: 3px;
  margin: 1px 10px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft), 0 8px 22px rgba(21, 26, 32, 0.14);
  opacity: 0;
  transform: scaleX(0.84);
  transform-origin: center;
  transition: opacity 120ms ease, transform 120ms ease;
}

.todo-drop-indicator.is-active {
  opacity: 1;
  transform: scaleX(1);
}

.is-reordering-todo .todo-row:not(.is-lifted-source):not(.todo-drag-ghost) {
  opacity: 0.74;
}

.is-reordering-todo {
  overflow: hidden;
  overscroll-behavior: none;
}

.row-main {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.row-title {
  overflow: hidden;
  font-size: 16px;
  font-weight: 500;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-meta {
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  font-weight: 390;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.small-check {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--accent-text);
  font-size: 14px;
  font-weight: 650;
}

.list-row.is-done {
  opacity: 0.52;
  background: transparent;
}

.shopping-row.is-done {
  opacity: 1;
}

.shopping-row.is-done .shopping-toggle {
  opacity: 0.52;
}

.list-row.is-done .small-check {
  border-color: transparent;
  background: var(--accent);
}

.list-row.is-done .row-title {
  color: var(--muted);
  text-decoration: line-through;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--text);
  outline: none;
}

input {
  min-height: 50px;
  padding: 0 14px;
}

textarea {
  min-height: 112px;
  padding: 13px 14px;
  line-height: 1.45;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: var(--faint);
}

input:focus,
textarea:focus {
  border-color: color-mix(in srgb, var(--accent) 62%, transparent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.sheet-dialog {
  width: min(460px, calc(100% - 24px));
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
}

.sheet-dialog::backdrop {
  background: rgba(0, 0, 0, 0.44);
  backdrop-filter: blur(10px);
}

.sheet-dialog form {
  display: grid;
  gap: 14px;
  border-radius: 8px;
  padding: 18px;
}

.sheet-dialog p {
  color: var(--muted);
}

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

.mode-picker {
  display: grid;
  gap: 10px;
}

.mode-card {
  min-height: 86px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--text);
  padding: 15px;
  text-align: left;
  transition: transform 150ms ease, background 150ms ease;
}

.mode-card span {
  display: block;
  font-size: 18px;
  font-weight: 540;
}

.mode-card small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 390;
  line-height: 1.35;
}

.composer-panel,
.edit-field-group {
  display: grid;
  gap: 12px;
}

.field-stack,
.date-field,
.repeat-field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 470;
}

.field-stack em,
.date-field em,
.repeat-field em {
  color: var(--faint);
  font-style: normal;
  font-weight: 390;
}

.control-row {
  display: flex;
  gap: 12px;
  align-items: end;
}

.split {
  justify-content: space-between;
}

.compact-field {
  min-width: min(260px, 50%);
}

.pill-group {
  display: flex;
  gap: 9px;
  align-items: center;
}

.avatar-pill {
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 17px;
  font-weight: 540;
}

.avatar-pill[aria-pressed="true"] {
  border-color: transparent;
  background: var(--accent);
  color: var(--accent-text);
}

.toggle-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.switch-button {
  position: relative;
  width: 54px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-muted);
  padding: 0;
}

.switch-button span {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--surface-strong);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.14);
  transition: transform 160ms ease;
}

.switch-button[aria-pressed="true"] {
  border-color: transparent;
  background: var(--accent);
}

.switch-button[aria-pressed="true"] span {
  transform: translateX(22px);
}

.repeat-grid,
.retention-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.repeat-grid button,
.retention-grid button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--muted);
  padding: 0 12px;
  font-size: 13px;
  font-weight: 470;
}

.repeat-grid button[aria-pressed="true"],
.retention-grid button[aria-pressed="true"] {
  border-color: transparent;
  background: var(--accent);
  color: var(--accent-text);
}

.primary-action,
.danger-action {
  min-height: 50px;
  border: 0;
  border-radius: 999px;
  padding: 0 18px;
  font-weight: 620;
}

.primary-action {
  background: var(--accent);
  color: var(--accent-text);
}

.danger-action {
  background: var(--danger-soft);
  color: var(--danger);
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.shopping-preview {
  min-height: 20px;
}

.preview-summary {
  color: var(--muted);
  font-size: 14px;
  font-weight: 420;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 18px;
  text-align: center;
  font-size: 14px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 10;
  max-width: calc(100% - 32px);
  transform: translate(-50%, 120%);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  opacity: 0;
  padding: 11px 16px;
  font-size: 14px;
  font-weight: 500;
  transition: transform 180ms ease, opacity 180ms ease;
}

.toast.is-visible {
  transform: translate(-50%, 0);
  opacity: 1;
}

.is-hidden {
  display: none !important;
}

@media (max-width: 560px) {
  .app-shell {
    padding-inline: 12px;
  }

  h1 {
    font-size: 32px;
  }

  .hero-card {
    min-height: 138px;
    padding: 18px;
  }

  .hero-card h2 {
    font-size: 27px;
  }

  .home-card {
    min-height: 88px;
    padding: 15px;
  }

  .control-row.split {
    align-items: stretch;
    flex-direction: column;
  }

  .compact-field {
    min-width: 0;
  }

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