:root {
  --bg: #f6f1e9;
  --card: #fffdf9;
  --ink: #2b2723;
  --muted: #7a7168;
  --line: #e6ded2;
  --accent: #d9534b;
  --accent-ink: #fff;
  --error: #a3322a;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d1b19;
    --card: #282522;
    --ink: #efe9e1;
    --muted: #a39a90;
    --line: #3a3632;
    --accent: #f08880;
    --accent-ink: #1d1b19;
    --error: #f0978d;
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.6 -apple-system, 'PingFang TC', 'Noto Sans TC', 'Microsoft JhengHei', system-ui, sans-serif;
}

body::before {
  content: '';
  display: block;
  height: calc(env(safe-area-inset-top) + 6px);
  background: linear-gradient(90deg, #e8564f 0 20%, #f6c744 20% 40%, #45bd85 40% 60%, #5a6cf0 60% 80%, #8d97a1 80% 100%);
}

#app {
  max-width: 34rem;
  margin: 0 auto;
  padding: 1rem 1rem calc(env(safe-area-inset-bottom) + 2rem);
}

h1 {
  font-size: 1.5rem;
  margin: 0;
}

h2 {
  font-size: 1.1rem;
  margin: 0;
}

p {
  margin: 0;
}

hr {
  width: 100%;
  border: 0;
  border-top: 1px solid var(--line);
  margin: 0.5rem 0;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.25rem;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.row {
  display: flex;
  gap: 0.5rem;
}

.row input {
  flex: 1;
  min-width: 0;
}

.grow {
  flex: 1;
  min-width: 0;
}

.center {
  text-align: center;
}

.muted {
  color: var(--muted);
  font-size: 0.95rem;
}

.error {
  color: var(--error);
  font-size: 0.95rem;
}

[hidden] {
  display: none !important;
}

input[type='text'] {
  font: inherit;
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.65rem 0.8rem;
  width: 100%;
}

input[type='text']:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* 勾選框：空的是一個圓圈；勾起來變成草莓（待辦清單是紫水晶） */
input[type='checkbox'] {
  appearance: none;
  -webkit-appearance: none;
  width: 1.7rem;
  height: 1.7rem;
  flex: none;
  margin: 0;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: var(--bg) center / contain no-repeat;
  cursor: pointer;
}

input[type='checkbox']:checked {
  border-color: transparent;
  border-radius: 0;
  background-color: transparent;
  background-image: url('/art/strawberry.svg');
}

.list.shopping .alt input[type='checkbox']:checked {
  background-image: url('/art/egg.svg');
}

.list.todo input[type='checkbox']:checked {
  background-image: url('/art/gem.svg');
}

input[type='checkbox']:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.art {
  display: block;
  margin: 0 auto;
  max-width: 100%;
}

.art.hero {
  width: 17rem;
}

.art.small {
  width: 6.5rem;
  margin-bottom: 0.6rem;
}

.art.scene {
  width: 14rem;
  margin-top: 1.75rem;
}

.empty {
  padding: 1rem 0 0.5rem;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: 0;
  background: none;
  border-radius: 10px;
  padding: 0.65rem 1rem;
}

button.primary {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
  white-space: nowrap;
}

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

button.link {
  color: var(--muted);
  font-size: 0.95rem;
  text-decoration: underline;
  padding: 0.4rem;
  align-self: center;
}

button.icon {
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
  padding: 0.6rem 0.7rem;
}

.tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 0.75rem;
}

.tab {
  flex: 1;
  color: var(--muted);
  padding: 0.6rem 0.25rem;
}

.tab.active {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--ink);
  font-weight: 600;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.list li {
  display: flex;
  align-items: center;
  border-top: 1px solid var(--line);
}

.list li:first-child {
  border-top: 0;
}

.check {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.7rem 0;
  cursor: pointer;
}

.check span {
  overflow-wrap: anywhere;
}

.done .check span {
  color: var(--muted);
  text-decoration: line-through;
}

.code {
  font: 600 1.15rem/1.9 ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  letter-spacing: 0.05em;
  text-align: center;
  background: var(--bg);
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 0.9rem;
  user-select: all;
  overflow-wrap: anywhere;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 1.25rem);
  transform: translateX(-50%);
  max-width: calc(100% - 2rem);
  background: var(--ink);
  color: var(--bg);
  border-radius: 12px;
  padding: 0.65rem 1rem;
  font-size: 0.95rem;
}
