*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:            #d4c4a8;
  --card:          #f0e6d6;
  --header-bg:     #1c1a14;
  --accent:        #b86e2a;
  --accent-hover:  #96581f;
  --accent-light:  #f5ece0;
  --text-1:        #1c1a14;
  --text-2:        #5c4f3a;
  --text-3:        #9a8870;
  --border:        #c8b494;
  --border-2:      #b09878;
  --section-hd:    #e8d8c0;
  --done-bg:       #dff0e0;
  --done-fg:       #3a6e3a;
  --warn-border:   #e8c870;
  --warn-bg:       #faf0d8;
  --font:          'Instrument Sans', system-ui, sans-serif;
  --r:             10px;
  --r-sm:          6px;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-1);
  min-height: 100vh;
  line-height: 1.5;
}

.inner {
  max-width: 700px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* ---- Header ---- */
.app-header {
  background: var(--header-bg);
  padding: 1.25rem 0 1.1rem;
  border-bottom: 1px solid #2e2a1e;
}
.header-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 3px;
}
.logo-icon {
  width: 30px;
  height: 30px;
  background: var(--accent);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #fff;
}
.app-header h1 {
  font-size: 17px;
  font-weight: 600;
  color: #ffffff;
  letter-spacing: -0.2px;
}
.tagline {
  font-size: 12px;
  color: #8a7a60;
  padding-left: 40px;
}

/* ---- Main layout ---- */
main.inner {
  padding-top: 1.25rem;
  padding-bottom: 3rem;
}

/* ---- Input card ---- */
.input-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  margin-bottom: 8px;
  overflow: hidden;
  transition: border-color 0.15s;
}
.input-card:focus-within { border-color: var(--border-2); }
.input-card textarea {
  width: 100%;
  min-height: 120px;
  padding: 14px 16px;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  color: var(--text-1);
  background: transparent;
  border: none;
  outline: none;
  resize: vertical;
  display: block;
}
.input-card textarea::placeholder { color: var(--text-3); }
.input-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  border-top: 1px solid var(--border);
  background: #ecddc8;
}
.hint { font-size: 11px; color: var(--text-3); }
.btn-row { display: flex; gap: 7px; }

/* ---- Add bar ---- */
.add-bar {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  margin-bottom: 1.25rem;
  transition: border-color 0.15s;
}
.add-bar:focus-within { border-color: var(--border-2); }
.add-bar-inner {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 14px;
  height: 44px;
}
.add-icon {
  font-size: 12px;
  color: var(--text-3);
  margin-right: 10px;
  flex-shrink: 0;
}
.add-bar-inner input {
  flex: 1;
  border: none;
  outline: none;
  font-family: var(--font);
  font-size: 16px;
  color: var(--text-1);
  background: transparent;
  min-width: 0;
}
.add-bar-inner input::placeholder { color: var(--text-3); }
.btn-add {
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
  flex-shrink: 0;
}
.btn-add:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-add:active { transform: scale(0.97); }

/* ---- Buttons ---- */
button {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background 0.1s, transform 0.08s;
  border: none;
  outline: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
button:active { transform: scale(0.97); }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--section-hd); }

.btn-clear-list {
  font-size: 11px;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--text-3);
  border: 1px solid var(--border);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}
.btn-clear-list:hover {
  background: #f5ddd8;
  color: #b33;
  border-color: #f5b8b8;
}

/* ---- Progress ---- */
.progress-wrap { margin-bottom: 1rem; }
.progress-wrap.hidden { display: none; }
.progress-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.progress-label > span { font-size: 12px; color: var(--text-3); }
.progress-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
#progress-pct { font-size: 12px; color: var(--text-3); }
.progress-track {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.35s ease;
  width: 0%;
}

/* ---- Results ---- */
#results { display: flex; flex-direction: column; gap: 8px; }

/* ---- Section ---- */
.section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}
.section.all-done { border-color: #dde8e2; opacity: 0.72; }
.section.all-done .section-hd { background: var(--done-bg); }

.section-hd {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  background: var(--section-hd);
  cursor: pointer;
  user-select: none;
  transition: background 0.1s;
}
.section-hd:hover { background: #deccaa; }

.sec-icon {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  background: var(--card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-2);
  flex-shrink: 0;
}
.section.all-done .sec-icon {
  background: var(--done-bg);
  border-color: #b8d4c4;
  color: var(--done-fg);
}

.sec-label {
  flex: 1;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.sec-meta { display: flex; align-items: center; gap: 8px; }
.sec-count { font-size: 12px; color: var(--text-3); }
.done-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
  background: var(--done-bg);
  color: var(--done-fg);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.chevron {
  font-size: 11px;
  color: var(--text-3);
  transition: transform 0.2s ease;
  width: 12px;
  text-align: center;
}
.chevron.up { transform: rotate(0deg); }
.chevron.down { transform: rotate(-90deg); }

/* ---- Items collapse ---- */
.items-wrap {
  max-height: 2000px;
  overflow: hidden;
  transition: max-height 0.28s ease;
}
.items-wrap.collapsed { max-height: 0; }

/* ---- Item row ---- */
.item-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 14px;
  cursor: pointer;
  transition: background 0.08s;
}
.item-row + .item-row,
.cat-picker + .item-row { border-top: 1px solid var(--border); }
.item-row:hover,
.item-row.picking { background: #ecddc8; }
.item-row input[type="checkbox"] {
  width: 15px;
  height: 15px;
  cursor: pointer;
  accent-color: var(--accent);
  flex-shrink: 0;
}
.item-label {
  font-size: 14px;
  color: var(--text-1);
  flex: 1;
  transition: color 0.15s;
}
.item-row.checked .item-label {
  text-decoration: line-through;
  color: var(--text-3);
}

/* ---- Action buttons ---- */
.item-actions {
  display: flex;
  gap: 2px;
  opacity: 1;
  flex-shrink: 0;
}
.action-btn {
  width: 24px;
  height: 24px;
  border-radius: var(--r-sm);
  border: none;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  padding: 0;
  transition: background 0.1s, color 0.1s;
}
.action-btn:active { transform: scale(0.95); }
.action-btn:hover { background: var(--border); color: var(--text-1); }
.action-btn.del-btn:hover { background: #e8c0b8; color: #7a1a10; }

/* ---- Category picker ---- */
.cat-picker {
  display: none;
  padding: 8px 14px 10px 40px;
  background: var(--section-hd);
  flex-direction: column;
  gap: 8px;
  border-top: 1px solid var(--border);
}
.cat-picker.open { display: flex; }
.cat-group { display: flex; flex-direction: column; gap: 4px; }
.cat-group-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-3);
}
.cat-group-pills { display: flex; flex-wrap: wrap; gap: 5px; }
.cat-pill {
  font-size: 11px;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 20px;
  border: 1px solid var(--border-2);
  background: var(--card);
  color: var(--text-2);
  cursor: pointer;
  font-family: var(--font);
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}
.cat-pill:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.cat-pill.is-current {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 600;
  cursor: default;
}
.cat-pill.is-current:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

/* ---- Flash animation for newly added items ---- */
@keyframes flash-in {
  from { background: #d4edde; }
  to   { background: transparent; }
}
.item-row.new-item { animation: flash-in 1.2s ease forwards; }

/* ---- Unknown section ---- */
.section.unknown .section-hd { background: var(--warn-bg); }
.section.unknown { border-color: var(--warn-border); }
.section.unknown .sec-icon { background: var(--warn-bg); border-color: var(--warn-border); color: #a07a00; }

@media (max-width: 520px) {
  .hint { display: none; }
  .input-card textarea { min-height: 90px; }
}
