:root {
  color-scheme: light;
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --warning: #d97706;
  --success: #16a34a;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.08);
  --radius: 22px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
body { -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; border: 0; }
textarea { min-height: 96px; resize: vertical; }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px clamp(16px, 4vw, 36px); background: rgba(248,250,252,0.86); backdrop-filter: blur(18px); border-bottom: 1px solid rgba(226,232,240,0.8); }
.brand { display: flex; align-items: center; gap: 12px; font-weight: 800; letter-spacing: -0.02em; }
.logo { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; background: linear-gradient(135deg, #2563eb, #7c3aed); color: white; box-shadow: var(--shadow); font-weight: 900; }
.top-actions { display: flex; gap: 10px; align-items: center; }
.main-layout { display: grid; grid-template-columns: 270px 1fr; gap: 24px; width: min(1440px, 100%); margin: 0 auto; padding: 22px clamp(14px, 3vw, 32px) 96px; }
.sidebar { position: sticky; top: 88px; align-self: start; display: grid; gap: 8px; padding: 12px; border-radius: var(--radius); background: rgba(255,255,255,0.88); border: 1px solid var(--line); box-shadow: var(--shadow); }
.nav-btn { width: 100%; display: flex; align-items: center; gap: 12px; padding: 13px 14px; border-radius: 16px; color: var(--muted); background: transparent; text-align: left; font-weight: 700; }
.nav-btn.active, .nav-btn:hover { color: var(--text); background: #eff6ff; }
.content { min-width: 0; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin: 6px 0 20px; }
.page-title { margin: 0; font-size: clamp(26px, 4vw, 40px); letter-spacing: -0.045em; }
.page-subtitle { margin: 8px 0 0; color: var(--muted); line-height: 1.5; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card.compact { padding: 14px; }
.metric { display: grid; gap: 6px; }
.metric .value { font-size: 28px; font-weight: 900; letter-spacing: -0.04em; }
.metric .label { color: var(--muted); font-weight: 700; }
.list { display: grid; gap: 12px; }
.item { display: grid; gap: 8px; padding: 14px; border-radius: 18px; border: 1px solid var(--line); background: #fff; }
.item-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.item-title { font-weight: 850; }
.item-meta { color: var(--muted); font-size: 14px; line-height: 1.4; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 999px; background: #f1f5f9; color: #475569; font-size: 12px; font-weight: 800; white-space: nowrap; }
.badge.green { background: #dcfce7; color: #166534; }
.badge.yellow { background: #fef3c7; color: #92400e; }
.badge.red { background: #fee2e2; color: #991b1b; }
.badge.blue { background: #dbeafe; color: #1e40af; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 10px 14px; border-radius: 14px; font-weight: 850; background: #e2e8f0; color: #0f172a; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.danger { background: #fee2e2; color: #991b1b; }
.btn.success { background: #dcfce7; color: #166534; }
.btn.small { min-height: 34px; padding: 7px 10px; border-radius: 12px; font-size: 13px; }
.btn.full { width: 100%; }
.form { display: grid; gap: 14px; }
.form-row { display: grid; gap: 7px; }
label { font-size: 13px; color: #475569; font-weight: 850; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 14px; padding: 12px 13px; background: white; color: var(--text); outline: none; }
input:focus, select:focus, textarea:focus { border-color: #93c5fd; box-shadow: 0 0 0 4px #dbeafe; }
.input-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.empty { color: var(--muted); border: 1px dashed #cbd5e1; border-radius: 18px; padding: 18px; background: #f8fafc; }
.notice { border-radius: 18px; padding: 14px; border: 1px solid #bfdbfe; background: #eff6ff; color: #1e3a8a; line-height: 1.5; }
.notice.warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.notice.danger { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.notice.success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }

.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at top left, #dbeafe, transparent 32%), radial-gradient(circle at bottom right, #ede9fe, transparent 28%), var(--bg); }
.auth-card { width: min(470px, 100%); }
.auth-title { font-size: 34px; margin: 12px 0 8px; letter-spacing: -0.05em; }
.auth-copy { color: var(--muted); line-height: 1.55; margin-bottom: 18px; }
.tabbar { display: flex; gap: 8px; padding: 5px; border-radius: 16px; background: #f1f5f9; margin-bottom: 16px; }
.tabbar button { flex: 1; padding: 10px; border-radius: 12px; background: transparent; font-weight: 850; color: var(--muted); }
.tabbar button.active { background: white; color: var(--text); box-shadow: 0 5px 14px rgba(15,23,42,0.06); }

.modal-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(15, 23, 42, 0.46); display: grid; place-items: end center; padding: 20px; }
.modal { width: min(760px, 100%); max-height: min(88vh, 900px); overflow: auto; background: white; border-radius: 28px; border: 1px solid var(--line); box-shadow: 0 30px 80px rgba(15,23,42,0.25); padding: 20px; }
.modal-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; margin-bottom: 14px; }
.modal-title { margin: 0; font-size: 24px; letter-spacing: -0.035em; }

.suggestion-list { display: grid; gap: 8px; max-height: 280px; overflow: auto; }
.suggestion { display: grid; gap: 4px; padding: 12px; border-radius: 16px; border: 1px solid var(--line); background: #f8fafc; text-align: left; }
.suggestion:hover { border-color: #93c5fd; background: #eff6ff; }
.recipe-steps { margin: 8px 0 0 18px; color: #334155; }
.recipe-steps li { margin: 6px 0; }

.install-banner { position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 30; display: none; align-items: center; justify-content: space-between; gap: 12px; padding: 14px; border-radius: 18px; background: #0f172a; color: white; box-shadow: var(--shadow); }
.install-banner.show { display: flex; }
.install-banner small { color: #cbd5e1; }

.legal-page { padding: 24px; }
.legal-card { max-width: 860px; margin: 0 auto; background: white; border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); padding: clamp(20px, 5vw, 42px); line-height: 1.65; }
.legal-card h1 { letter-spacing: -0.04em; }
.legal-card h2 { margin-top: 28px; }

@media (max-width: 920px) {
  .main-layout { grid-template-columns: 1fr; padding-bottom: 92px; }
  .sidebar { position: fixed; left: 10px; right: 10px; bottom: 10px; top: auto; z-index: 20; grid-template-columns: repeat(5, minmax(0, 1fr)); padding: 8px; border-radius: 22px; }
  .nav-btn { justify-content: center; padding: 10px 8px; font-size: 0; }
  .nav-btn span:first-child { font-size: 20px; }
  .grid.two, .grid.three, .grid.four { grid-template-columns: 1fr; }
  .input-grid { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; }
  .top-actions .user-email { display: none; }
}

@media (prefers-color-scheme: dark) {
  :root { color-scheme: dark; --bg: #020617; --card: #0f172a; --text: #e2e8f0; --muted: #94a3b8; --line: #1e293b; --shadow: 0 18px 45px rgba(0, 0, 0, 0.25); }
  .topbar { background: rgba(2,6,23,0.88); border-color: #1e293b; }
  .sidebar, .card, .item, input, select, textarea, .modal, .legal-card { background: #0f172a; color: var(--text); }
  .item, .empty, .suggestion { background: #111827; }
  .nav-btn.active, .nav-btn:hover { background: #1e293b; }
  .tabbar { background: #111827; }
  .tabbar button.active { background: #1e293b; }
}
