/* ── Reset & Root ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:      #2563EB;
  --primary-dark: #1D4ED8;
  --primary-soft: rgba(37, 99, 235, 0.1);
  --surface:      #F8FAFF;
  --card:         #FFFFFF;
  --border:       #E2E8F0;
  --text:         #0F172A;
  --text-muted:   #64748B;
  --success:      #16A34A;
  --warn:         #E8900C;
  --warn-soft:    rgba(232, 144, 12, 0.12);
  --danger:       #DC2626;
  --danger-soft:  rgba(220, 38, 38, 0.08);
  --radius:       12px;
  --radius-sm:    8px;
  --shadow:       0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:    0 4px 16px rgba(0,0,0,.10);
}

html {
  background: var(--surface);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue',
               'Hiragino Sans', 'Hiragino Kaku Gothic ProN', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100dvh; }

/* ── Typography ─────────────────────────────────────────── */
h1 { font-size: 1.6rem; font-weight: 700; line-height: 1.2; }
h2 { font-size: 1.2rem; font-weight: 600; }

/* ── Button ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, opacity .15s;
  white-space: nowrap;
  font-family: inherit;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

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

.btn-outline  { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover:not(:disabled) { background: var(--primary-soft); }

.btn-ghost    { background: transparent; color: var(--text-muted); border: 1.5px solid var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--border); }

.btn-warn     { background: var(--warn-soft); color: var(--warn); border: 1.5px solid rgba(232,144,12,.25); }
.btn-danger   { background: var(--danger-soft); color: var(--danger); border: 1.5px solid rgba(220,38,38,.2); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; }

/* ── Form ───────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 13px; font-weight: 600; color: var(--text); }

.form-input {
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: var(--card);
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.form-input::placeholder { color: var(--text-muted); }

.form-error {
  font-size: 12px;
  color: var(--danger);
  display: none;
}
.form-error.visible { display: block; }

/* ── Card ───────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ── Badge ──────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
}
.badge-temporary  { background: var(--surface);     color: var(--text-muted); border: 1px solid var(--border); }
.badge-bookmarked { background: var(--warn-soft);   color: var(--warn);       border: 1px solid rgba(232,144,12,.3); }

/* ── Toast ──────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--text);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  transition: transform .25s ease, opacity .25s ease;
  opacity: 0;
  z-index: 1000;
  white-space: nowrap;
  pointer-events: none;
}
#toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}
#toast.success { background: var(--success); }
#toast.error   { background: var(--danger); }

/* ── Loading spinner ────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Empty state ────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 56px 24px;
  color: var(--text-muted);
}
.empty-state-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state-text { font-size: 15px; margin-bottom: 8px; color: var(--text); font-weight: 600; }
.empty-state-sub  { font-size: 13px; }

/* ── Overlay / Modal ────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
  z-index: 100;
}
.overlay.open { opacity: 1; pointer-events: all; }

.sheet {
  background: var(--card);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 24px 20px 32px;
  width: 100%;
  max-width: 480px;
  transform: translateY(100%);
  transition: transform .25s ease;
}
.overlay.open .sheet { transform: translateY(0); }

.sheet-handle {
  width: 36px; height: 4px;
  border-radius: 2px;
  background: var(--border);
  margin: 0 auto 20px;
}
.sheet-title { font-size: 16px; font-weight: 700; margin-bottom: 20px; }

@media (min-width: 480px) {
  .overlay { align-items: center; }
  .sheet {
    border-radius: var(--radius);
    max-width: 440px;
    transform: scale(.95);
    padding: 28px 24px;
  }
  .overlay.open .sheet { transform: scale(1); }
  .sheet-handle { display: none; }
}
