:root {
  --bg: #eef2ff;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-2: rgba(241, 245, 249, 0.9);
  --surface-solid: #ffffff;
  --border: rgba(15, 23, 42, 0.1);
  --border-top: rgba(255, 255, 255, 0.9);
  --text: #090d16;
  --muted: #475569;
  --accent: #4f46e5;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --shadow-3d: 0 2px 0 rgba(255,255,255,0.85) inset, 0 18px 40px -14px rgba(15, 23, 42, 0.14), 0 4px 12px rgba(15, 23, 42, 0.06);
  --shadow-hover: 0 2px 0 rgba(255,255,255,0.95) inset, 0 28px 58px -12px rgba(79, 70, 229, 0.24), 0 8px 20px rgba(15, 23, 42, 0.1);
}

html[data-color-mode="dark"] {
  --bg: #050711;
  --surface: rgba(17, 22, 38, 0.72);
  --surface-2: rgba(26, 34, 56, 0.78);
  --surface-solid: #0f1526;
  --border: rgba(148, 163, 184, 0.18);
  --border-top: rgba(255, 255, 255, 0.24);
  --text: #f8fafc;
  --muted: #cbd5e1;
  --accent: #6366f1;
  --shadow-3d: 0 1px 0 rgba(255,255,255,0.16) inset, 0 -1px 0 rgba(0,0,0,0.4) inset, 0 22px 48px -12px rgba(0, 0, 0, 0.72);
  --shadow-hover: 0 1px 0 rgba(255,255,255,0.28) inset, 0 28px 60px -10px rgba(99, 102, 241, 0.32);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { touch-action: manipulation; }
body {
  font-family: "Pretendard Variable", "Pretendard", -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg); color: var(--text); min-height: 100dvh; line-height: 1.5;
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
.svg-ico, .emblem-svg { flex-shrink: 0; display: inline-block; vertical-align: middle; }
.container { max-width: 1180px; margin: 0 auto; padding: 0 20px; position: relative; z-index: 1; }

/* 3D Spatial Atmosphere */
.spatial-bg { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.aurora-blob { position: absolute; border-radius: 50%; filter: blur(95px); opacity: 0.45; }
.blob-a { width: 520px; height: 520px; top: -180px; left: -120px; background: radial-gradient(circle, #6366f1, #06b6d4); }
.blob-b { width: 480px; height: 480px; bottom: -160px; right: -100px; background: radial-gradient(circle, #ec4899, #4f46e5); opacity: 0.32; }
.horizon-grid {
  position: absolute; inset: 0; opacity: 0.28;
  background-image: linear-gradient(var(--border) 1px, transparent 1px), linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at 50% 25%, black 35%, transparent 80%);
}

/* Header */
.topbar {
  position: sticky; top: 0; z-index: 30;
  padding-top: env(safe-area-inset-top);
  backdrop-filter: blur(22px) saturate(160%); -webkit-backdrop-filter: blur(22px) saturate(160%);
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 20px; }
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; overflow: hidden;
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.35);
}
.brand-mark img { width: 100%; height: 100%; display: block; }
.brand-title { font-size: 0.98rem; font-weight: 800; letter-spacing: 0.08em; line-height: 1.15; }
.brand-sub { font-size: 0.72rem; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: 6px; }

.pill-btn, .btn-outline, .btn-primary, .btn-danger-ghost {
  border: 1px solid var(--border); border-top-color: var(--border-top); border-radius: 11px;
  padding: 8px 13px; min-height: 38px; cursor: pointer; background: var(--surface);
  font-size: 0.82rem; font-weight: 700; display: inline-flex; align-items: center; gap: 6px;
  backdrop-filter: blur(12px); transition: transform 0.16s ease, box-shadow 0.16s ease;
}
.pill-btn.icon-only { padding: 8px 10px; }
.pill-btn:hover, .btn-outline:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn-primary {
  background: linear-gradient(145deg, #4f46e5, #06b6d4); color: #fff; border: 0;
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.4), 0 8px 20px -4px rgba(79, 70, 229, 0.55);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: inset 0 1px 1px rgba(255,255,255,0.5), 0 12px 26px -4px rgba(6, 182, 212, 0.55); }
.btn-danger-ghost { color: #f87171; border-color: rgba(248, 113, 113, 0.35); background: transparent; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.pill-btn.is-synced .status-dot { background: #10b981; box-shadow: 0 0 10px #10b981; }

.main-wrap { padding: 22px 20px calc(92px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 22px; }

/* 3D Spatial Glass Cards */
.surface-card {
  background: var(--surface); border: 1px solid var(--border); border-top-color: var(--border-top);
  border-radius: 24px; box-shadow: var(--shadow-3d);
  backdrop-filter: blur(20px) saturate(140%); -webkit-backdrop-filter: blur(20px) saturate(140%);
}
.hero-stage, .bento-card {
  position: relative; overflow: hidden;
  transform: perspective(1000px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateZ(0);
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.25s ease;
  will-change: transform;
}
.hero-stage.is-tilting, .bento-card.is-tilting { transition: transform 0.06s linear; }
.bento-card:hover { box-shadow: var(--shadow-hover); }
.card-sheen {
  position: absolute; inset: 0; pointer-events: none; z-index: 2; opacity: 0; transition: opacity 0.25s ease;
  background: radial-gradient(360px circle at var(--mx, 50%) var(--my, 20%), rgba(255,255,255,0.22), transparent 60%);
}
.is-tilting > .card-sheen { opacity: 1; }

/* High-Clarity Status Pills */
.status-pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px;
  font-size: 0.7rem; font-weight: 800; letter-spacing: 0.04em;
}
.st-today { background: #ef4444; color: #fff; box-shadow: 0 0 14px rgba(239, 68, 68, 0.55); }
.st-urgent { background: rgba(249, 115, 22, 0.2); color: #fb923c; border: 1px solid rgba(249, 115, 22, 0.45); }
.st-upcoming { background: rgba(79, 70, 229, 0.16); color: #818cf8; border: 1px solid rgba(99, 102, 241, 0.35); }
.st-countup { background: rgba(236, 72, 153, 0.18); color: #f472b6; border: 1px solid rgba(236, 72, 153, 0.4); }
.st-passed { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
html:not([data-color-mode="dark"]) .st-upcoming { color: #4338ca; }
html:not([data-color-mode="dark"]) .st-urgent { color: #c2410c; }
html:not([data-color-mode="dark"]) .st-countup { color: #be185d; }

/* 3D Medallion */
.emblem-medallion {
  width: 48px; height: 48px; border-radius: 15px; flex-shrink: 0; display: grid; place-items: center;
  color: #fff; background: linear-gradient(145deg, var(--med-accent, #4f46e5), color-mix(in srgb, var(--med-accent, #4f46e5) 60%, #06b6d4));
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.55), 0 8px 20px -4px var(--med-soft, rgba(79,70,229,0.55));
}
.emblem-medallion.lg { width: 60px; height: 60px; border-radius: 18px; }
.emblem-medallion.sm { width: 38px; height: 38px; border-radius: 11px; }

/* Hero Stage */
.hero-stage { padding: 28px; }
.hero-ambient { position: absolute; inset: 0; pointer-events: none; background: radial-gradient(650px circle at 88% 12%, var(--card-soft, rgba(79,70,229,0.22)), transparent 65%); }
.hero-grid { position: relative; z-index: 3; display: grid; grid-template-columns: 1.4fr 1fr; gap: 26px; align-items: center; }
.hero-info { display: flex; flex-direction: column; gap: 15px; }
.hero-kicker { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-family: var(--mono); font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em; color: var(--muted); }
.pulse-dot { width: 8px; height: 8px; border-radius: 50%; box-shadow: 0 0 10px var(--card-accent); }
.meta-badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 7px; background: var(--surface-2); color: var(--text); font-size: 0.69rem; }
.hero-headline { display: flex; align-items: center; gap: 16px; }
.hero-title { font-size: clamp(1.45rem, 2.7vw, 2.15rem); font-weight: 900; letter-spacing: -0.025em; line-height: 1.15; }
.hero-date { font-size: 0.9rem; color: var(--muted); margin-top: 4px; font-family: var(--mono); }
.hero-date strong { color: var(--text); }
.hero-note { font-size: 0.92rem; color: var(--muted); }

.hero-clock { display: grid; grid-template-columns: repeat(4, minmax(64px, 96px)); gap: 10px; }
.clock-cell {
  background: var(--surface-2); border: 1px solid var(--border); border-top-color: var(--border-top);
  border-radius: 16px; padding: 12px 8px; text-align: center;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.16), 0 8px 18px rgba(0,0,0,0.12);
}
.clock-cell span { display: block; font-family: var(--mono); font-size: 1.7rem; font-weight: 800; line-height: 1.05; font-variant-numeric: tabular-nums; }
.clock-cell small { font-size: 0.68rem; font-weight: 700; color: var(--muted); }

.hero-gauge-col { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.orbital-core { position: relative; width: 184px; height: 184px; display: grid; place-items: center; }
.orbit-halo {
  position: absolute; inset: 12px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, var(--card-soft, rgba(99,102,241,0.32)), transparent 68%);
  filter: blur(10px);
}
.ring-svg { width: 184px; height: 184px; position: relative; z-index: 2; filter: drop-shadow(0 0 16px var(--card-soft, rgba(99,102,241,0.45))); }
.ring-outer-hairline { fill: none; stroke: var(--border); stroke-width: 1; stroke-dasharray: 4 6; opacity: 0.7; }
.ring-track { fill: none; stroke: var(--surface-2); stroke-width: 6; }
.ring-fill { fill: none; stroke-width: 6.5; stroke-linecap: round; transform: rotate(-90deg); transform-origin: 84px 84px; transition: stroke-dashoffset 0.5s ease; }
.ring-tip-glow { opacity: 0.55; filter: blur(2px); }
.ring-sphere {
  position: absolute; z-index: 3; width: 120px; height: 120px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  background: linear-gradient(155deg, color-mix(in srgb, var(--surface-solid) 86%, #fff), var(--surface-2));
  border: 1px solid var(--border-top);
  box-shadow: inset 0 2px 3px rgba(255,255,255,0.28), 0 14px 28px rgba(0,0,0,0.28);
}
.ring-badge { font-family: var(--mono); font-size: 1.85rem; font-weight: 900; letter-spacing: -0.04em; line-height: 1.05; }
.ring-pct {
  font-family: var(--mono); font-size: 0.72rem; font-weight: 800; margin-top: 4px;
  padding: 2px 8px; border-radius: 999px; background: var(--card-soft); color: var(--card-accent);
}
.hero-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }

.milestone-rail { position: relative; z-index: 3; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.rail-header { font-family: var(--mono); font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.rail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 9px; }
.rail-node { display: flex; align-items: center; gap: 9px; padding: 9px 11px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 13px; }
.rail-node.is-today { border-color: var(--card-accent); box-shadow: 0 0 16px var(--card-soft); }
.rail-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.rail-body { display: flex; flex-direction: column; font-size: 0.78rem; line-height: 1.25; }
.rail-body span { color: var(--muted); font-size: 0.7rem; font-family: var(--mono); }
.rail-delta { margin-left: auto; font-style: normal; font-family: var(--mono); font-size: 0.74rem; font-weight: 800; }

/* Presets, Toolbar & Cards */
.presets-strip, .category-pills { display: flex; align-items: center; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px; }
.presets-strip::-webkit-scrollbar, .category-pills::-webkit-scrollbar { display: none; }
.presets-strip { margin-bottom: 14px; }
.category-pills { margin: 12px 0 18px; }
.presets-title { display: inline-flex; align-items: center; gap: 5px; font-size: 0.76rem; font-weight: 700; color: var(--muted); white-space: nowrap; }
.preset-chip, .cat-pill {
  white-space: nowrap; flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  font-size: 0.8rem; font-weight: 700; cursor: pointer;
}
.cat-pill { color: var(--muted); }
.cat-pill.active { background: var(--text); color: var(--bg); border-color: transparent; }
.preset-ico { display: inline-flex; color: var(--accent); }

.board-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.board-heading { display: flex; align-items: center; gap: 9px; }
.board-heading h2 { font-size: 1.14rem; font-weight: 800; }
.count-badge { font-family: var(--mono); background: var(--surface-2); border: 1px solid var(--border); padding: 2px 9px; border-radius: 999px; font-size: 0.76rem; font-weight: 700; }
.filter-controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.segmented { display: inline-flex; padding: 3px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--border); }
.seg-btn { border: 0; background: transparent; padding: 6px 11px; border-radius: 8px; font-size: 0.78rem; font-weight: 700; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; gap: 5px; }
.seg-btn.active { background: var(--surface-solid); color: var(--text); box-shadow: var(--shadow-sm); }
.search-input, .sort-select, .field input, .field select, .field textarea, .sync-row input {
  background: var(--surface-solid); border: 1px solid var(--border); border-radius: 11px; padding: 9px 12px; font-size: 0.88rem;
}

.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.bento-card { display: flex; flex-direction: column; }
.bento-card.is-pinned { border-color: color-mix(in srgb, var(--card-accent) 55%, var(--border)); }
.card-accent-bar { height: 5px; width: 100%; }
.card-inner { position: relative; z-index: 3; padding: 17px 18px; display: flex; flex-direction: column; gap: 10px; flex: 1; background: radial-gradient(260px circle at 100% 0%, var(--card-soft, transparent), transparent 70%); }
.card-top-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card-badges { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.cat-tag { font-family: var(--mono); font-size: 0.7rem; font-weight: 700; color: var(--muted); text-transform: uppercase; }
.pin-btn { background: transparent; border: 0; border-radius: 8px; width: 32px; height: 32px; display: grid; place-items: center; cursor: pointer; color: var(--muted); }
.pin-btn.active { color: var(--card-accent); background: var(--surface-2); }
.card-metric-row { display: flex; justify-content: space-between; align-items: center; margin-top: 2px; }
.card-badge { font-family: var(--mono); font-size: 2rem; font-weight: 900; letter-spacing: -0.04em; text-shadow: 0 2px 12px var(--card-soft); }
.card-title { font-size: 1.12rem; font-weight: 800; letter-spacing: -0.015em; }
.card-meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 0.82rem; color: var(--muted); font-family: var(--mono); }
.card-meta strong { color: var(--text); }
.mini-tag { display: inline-flex; align-items: center; gap: 3px; background: var(--surface-2); padding: 2px 7px; border-radius: 6px; font-size: 0.7rem; font-weight: 700; color: var(--text); }
.card-prog-row { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 0.74rem; font-weight: 800; color: var(--muted); }
.micro-progress { flex: 1; height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.micro-fill { height: 100%; border-radius: 999px; }
.card-note { font-size: 0.86rem; color: var(--muted); }

.card-checklist { margin-top: 2px; padding-top: 9px; border-top: 1px dashed var(--border); display: flex; flex-direction: column; gap: 6px; }
.chk-head { font-family: var(--mono); font-size: 0.72rem; font-weight: 700; color: var(--muted); }
.chk-row { display: flex; gap: 8px; align-items: center; font-size: 0.85rem; cursor: pointer; min-height: 26px; }
.chk-row span.done { text-decoration: line-through; opacity: 0.52; }

.card-actions { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 6px; }
.icon-btn { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; width: 34px; height: 34px; cursor: pointer; display: grid; place-items: center; color: var(--text); }
.icon-btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.icon-btn.danger:hover { color: #ef4444; border-color: rgba(239, 68, 68, 0.45); }

/* Timeline, Modals, FAB, Toast */
.timeline-wrap { display: flex; flex-direction: column; gap: 22px; }
.tl-group-head { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 0.8rem; font-weight: 800; color: var(--muted); margin-bottom: 10px; }
.tl-group-head span { background: var(--surface-2); padding: 2px 8px; border-radius: 999px; }
.tl-list { display: flex; flex-direction: column; gap: 10px; border-left: 2px solid var(--border); padding-left: 16px; }
.tl-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; position: relative; flex-wrap: wrap; }
.tl-dot { position: absolute; left: -22px; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--bg); }
.tl-main { display: flex; flex-direction: column; flex: 1; min-width: 170px; }
.tl-main span { font-size: 0.8rem; color: var(--muted); }
.tl-badge { font-family: var(--mono); font-size: 1.2rem; font-weight: 900; margin-right: 6px; }
.tl-row .card-actions { margin-top: 0; padding-top: 0; border-top: 0; }
.empty-state, .hero-empty { padding: 40px 24px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--muted); }
.empty-glyph { width: 50px; height: 50px; border-radius: 14px; background: var(--surface-2); display: grid; place-items: center; color: var(--text); }
.shared-banner { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 18px; border-radius: 16px; background: var(--surface); border: 1px solid var(--accent); }
