:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --text: #1f2933;
  --muted: #687582;
  --line: #d9ded6;
  --accent: #2f7d57;
  --accent-strong: #236243;
  --accent-soft: #e2f1e8;
  --danger: #b33a3a;
  --danger-soft: #f8e5e3;
  --warning: #b66a20;
  --shadow: 0 14px 36px rgba(31, 41, 51, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

body {
  min-height: 100vh;
  margin: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

[hidden] {
  display: none !important;
}

.app-shell {
  width: min(860px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0)),
    var(--bg);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  gap: 12px;
  align-items: center;
  padding: 16px clamp(16px, 4vw, 32px);
  background: rgba(246, 244, 239, 0.94);
  border-bottom: 1px solid rgba(217, 222, 214, 0.78);
  backdrop-filter: blur(16px);
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.12;
}

.screen {
  padding: 20px clamp(16px, 4vw, 32px) 36px;
}

.toolbar,
.detail-head,
.add-row,
.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.toolbar,
.detail-head {
  justify-content: space-between;
  margin-bottom: 18px;
}

.list-grid {
  display: grid;
  gap: 12px;
}

.list-card,
.list-open {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  width: 100%;
}

.list-card {
  padding: 16px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.list-open {
  min-width: 0;
  padding: 0;
  color: inherit;
  text-align: left;
  background: transparent;
  border: 0;
}

.list-card strong,
.empty-state strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 18px;
}

.list-card span,
.empty-state span,
.hint {
  color: var(--muted);
}

.empty-state {
  padding: 28px;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: 8px;
  text-align: center;
}

.form-stack,
.items-panel {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
  width: 100%;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  color: var(--text);
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

input:disabled {
  color: var(--muted);
  background: #eef1ec;
  opacity: 1;
}

input:focus-visible,
button:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 125, 87, 0.2);
  outline: none;
}

.item-editor {
  display: grid;
  gap: 10px;
}

.command-button,
.ghost-button,
.danger-button,
.icon-button {
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid transparent;
}

.command-button {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  color: #ffffff;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 800;
}

.command-button:hover {
  background: var(--accent-strong);
}

.ghost-button {
  padding: 0 14px;
  color: var(--accent-strong);
  background: var(--accent-soft);
  border-color: rgba(47, 125, 87, 0.16);
  font-weight: 800;
}

.danger-button {
  width: 100%;
  padding: 0 14px;
  color: var(--danger);
  background: var(--danger-soft);
  border-color: rgba(179, 58, 58, 0.18);
  font-weight: 800;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  padding: 0;
  color: var(--text);
  background: var(--surface-strong);
  border-color: var(--line);
  font-size: 28px;
  line-height: 1;
}

.icon-button.primary {
  color: #ffffff;
  background: var(--accent);
  border-color: var(--accent);
}

.compact {
  width: 52px;
  padding: 0;
  font-size: 24px;
}

.wide {
  flex: 1;
}

.add-row {
  display: grid;
  grid-template-columns: 1fr 52px;
  margin-bottom: 14px;
}

.title-field input {
  font-size: 22px;
  font-weight: 800;
}

.item-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  gap: 8px;
  align-items: center;
  padding: 8px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.check-button {
  width: 36px;
  height: 36px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: #ffffff;
}

.check-button:focus-visible {
  outline: 3px solid rgba(47, 125, 87, 0.24);
  outline-offset: 2px;
}

.item-row.is-purchased .check-button {
  background: var(--accent);
}

.item-row.is-purchased .check-button::after {
  content: "✓";
  color: #ffffff;
  font-weight: 900;
}

.item-row.is-purchased .item-text {
  color: var(--muted);
  text-decoration: line-through;
}

.danger-zone {
  margin-top: 22px;
}

.hint {
  min-height: 22px;
  margin: 0;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  left: 16px;
  z-index: 6;
  max-width: 560px;
  margin: 0 auto;
  padding: 12px 14px;
  color: #ffffff;
  background: #25313b;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.toast button {
  margin-left: 12px;
  color: #ffffff;
  background: transparent;
  border: 0;
  font-weight: 900;
}

.loading {
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 560px) {
  .topbar {
    grid-template-columns: 40px 1fr 40px;
    padding-block: 12px;
  }

  .toolbar,
  .detail-head,
  .form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .command-button,
  .ghost-button {
    width: 100%;
  }

  .icon-button {
    width: 40px;
    min-height: 40px;
  }

  .item-row {
    grid-template-columns: 40px minmax(0, 1fr) 40px;
  }

  .detail-head .ghost-button {
    width: 100%;
  }
}
