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

:root {
  --bg: #f5f3ff;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #1a1a2e;
  --muted: #6b7280;
  --primary: #7c3aed;
  --primary-hover: #6d28d9;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --draw-bg: #059669;
  --draw-hover: #047857;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 25px rgba(0,0,0,.18);
}

body { font-family: system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

/* ── Auth overlay ── */
.auth-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 100; }
.auth-overlay.hidden { display: none; }
.auth-modal { background: var(--surface); border-radius: 14px; padding: 2rem; width: 100%; max-width: 400px; box-shadow: var(--shadow-lg); }
.auth-modal h2 { text-align: center; margin-bottom: 1.5rem; font-size: 1.5rem; }
.auth-tabs { display: flex; gap: .5rem; margin-bottom: 1.5rem; }
.auth-tab { flex: 1; padding: .5rem; border: 1px solid var(--border); background: none; border-radius: var(--radius); cursor: pointer; font-size: .9rem; color: var(--muted); transition: all .15s; }
.auth-tab.active { background: var(--primary); color: white; border-color: var(--primary); }
.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.auth-form.hidden { display: none; }
.auth-error { color: var(--danger); font-size: .875rem; min-height: 1.2rem; }
.optional { color: var(--muted); font-size: .78rem; font-weight: normal; }
.field-hint { font-size: .8rem; color: var(--muted); }

/* ── Form elements ── */
.form-group { display: flex; flex-direction: column; gap: .375rem; }
.form-group label { font-size: .875rem; font-weight: 500; }
input[type=text], input[type=email], input[type=password], textarea, .search-input {
  padding: .5rem .75rem; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: .9rem; font-family: inherit; outline: none; transition: border-color .15s;
  background: var(--surface); width: 100%;
}
input:focus, textarea:focus, .search-input:focus { border-color: var(--primary); }
textarea { resize: vertical; }

/* ── Buttons ── */
.btn { padding: .5rem 1rem; border-radius: var(--radius); border: none; cursor: pointer; font-size: .9rem; font-weight: 500; transition: background .15s; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #d1d5db; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-draw { background: var(--draw-bg); color: white; white-space: nowrap; }
.btn-draw:hover { background: var(--draw-hover); }
.btn-full { width: 100%; }
.btn-signout { background: none; border: 1px solid rgba(255,255,255,.4); color: white; padding: .35rem .75rem; border-radius: var(--radius); cursor: pointer; font-size: .85rem; transition: background .15s; }
.btn-signout:hover { background: rgba(255,255,255,.15); }
.close-btn { background: none; border: none; font-size: 1.25rem; cursor: pointer; color: var(--muted); line-height: 1; padding: 0; }
.close-btn:hover { color: var(--text); }

/* ── Header ── */
.header { background: var(--primary); color: white; padding: 1rem 1.5rem; }
.header-content { max-width: 820px; margin: auto; display: flex; align-items: center; justify-content: space-between; }
.header h1 { font-size: 1.2rem; letter-spacing: -.01em; }
.header-user { display: flex; align-items: center; gap: .75rem; font-size: .875rem; }

/* ── Layout ── */
.main { max-width: 820px; margin: 1.5rem auto; padding: 0 1rem; display: flex; flex-direction: column; gap: 1rem; }

/* ── Add section ── */
.add-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.add-section details summary {
  padding: .875rem 1rem; cursor: pointer; font-weight: 500; user-select: none;
  list-style: none; display: flex; align-items: center; justify-content: space-between;
  color: var(--primary);
}
.add-section details summary::-webkit-details-marker { display: none; }
.add-section details summary::after { content: '+'; font-size: 1.3rem; color: var(--primary); line-height: 1; }
.add-section details[open] summary::after { content: '\2212'; }
.add-section form { padding: 0 1rem 1rem; display: flex; flex-direction: column; gap: 1rem; }
.form-actions { display: flex; justify-content: flex-end; }

/* ── Tag chips input ── */
.tag-input-wrapper {
  display: flex; flex-wrap: wrap; gap: .375rem; align-items: center;
  border: 1px solid var(--border); border-radius: var(--radius); padding: .375rem .5rem;
  cursor: text; background: var(--surface); min-height: 40px;
}
.tag-input-wrapper:focus-within { border-color: var(--primary); }
.tag-input-wrapper input { border: none; outline: none; padding: .125rem .25rem; flex: 1; min-width: 100px; font-size: .875rem; background: transparent; }
#tag-chips-input { display: contents; }

/* ── Tag chips ── */
.chip {
  display: inline-flex; align-items: center; gap: .25rem;
  padding: .2rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 500;
}
.chip-remove { background: none; border: none; cursor: pointer; font-size: .85rem; line-height: 1; opacity: .65; padding: 0; color: inherit; }
.chip-remove:hover { opacity: 1; }
.chip-row { display: flex; flex-wrap: wrap; gap: .375rem; }

/* ── Filter section ── */
.filter-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .875rem 1rem; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: .625rem; }
.filter-row { display: flex; gap: .75rem; align-items: center; }
.search-input { flex: 1; }
.filter-tags { display: flex; flex-wrap: wrap; gap: .375rem; }
.filter-tag-chip { cursor: pointer; opacity: .5; transition: opacity .15s, transform .1s; }
.filter-tag-chip:hover { opacity: .8; }
.filter-tag-chip.active { opacity: 1; outline: 2px solid currentColor; outline-offset: 1px; }

/* ── Items list ── */
.items-list { display: flex; flex-direction: column; gap: .75rem; }
.item-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: .5rem; }
.item-top { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; }
.item-title { font-weight: 600; font-size: 1rem; line-height: 1.4; }
.item-delete { background: none; border: none; color: var(--border); cursor: pointer; font-size: 1.25rem; line-height: 1; padding: 0 .2rem; flex-shrink: 0; margin-top: -.1rem; transition: color .15s; }
.item-delete:hover { color: var(--danger); }
.item-description { font-size: .875rem; color: var(--muted); line-height: 1.55; white-space: pre-wrap; }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty-state h3 { font-size: 1.05rem; margin-bottom: .4rem; }

/* ── Draw overlay ── */
.draw-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 1rem; }
.draw-overlay.hidden { display: none; }
.draw-modal { background: var(--surface); border-radius: 14px; padding: 1.5rem; width: 100%; max-width: 480px; box-shadow: var(--shadow-lg); }
.draw-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.draw-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .07em; color: var(--draw-bg); font-weight: 700; }
.draw-modal h2 { font-size: 1.3rem; margin-bottom: .625rem; line-height: 1.35; }
.draw-description { color: var(--muted); font-size: .9rem; line-height: 1.6; white-space: pre-wrap; margin-bottom: .625rem; }
.draw-actions { display: flex; gap: .75rem; margin-top: 1.25rem; }
.draw-actions .btn { flex: 1; padding: .65rem 1rem; }
