/* AOX WBS — Apple-inspired design system */
:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Pretendard", "Apple SD Gothic Neo", system-ui, sans-serif;
  --font-mono: "SF Mono", ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
  --font-serif: "New York", "Times New Roman", "Noto Serif KR", serif;

  /* Light — translucent Apple-ish */
  --bg: #f5f5f7;
  --bg-elev: rgba(255,255,255,0.72);
  --bg-solid: #ffffff;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --fg: #1d1d1f;
  --fg-2: #3a3a3c;
  --fg-muted: #6e6e73;
  --fg-subtle: #8e8e93;
  --border: rgba(0,0,0,0.09);
  --border-strong: rgba(0,0,0,0.16);
  --divider: rgba(0,0,0,0.06);
  --hover: rgba(0,0,0,0.04);
  --selected: rgba(0,122,255,0.10);

  /* Accent — system blue by default, overridable */
  --accent: #007AFF;
  --accent-fg: #ffffff;
  --accent-soft: rgba(0,122,255,0.12);

  /* Phase colors */
  --phase1: #FF9500; /* amber */
  --phase2: #AF52DE; /* violet */
  --phase3: #007AFF; /* blue */
  --phase4: #34C759; /* green */

  /* Track colors — dev green, ops blue, PR orange (Apple system palette) */
  --track-dev: #34C759;
  --track-ops: #007AFF;
  --track-prm: #FF9500;

  /* Status colors */
  --status-notstarted: #8E8E93;
  --status-inprogress: #007AFF;
  --status-blocked: #FF453A;
  --status-done: #34C759;

  /* Risk */
  --risk-low: #34C759;
  --risk-med: #FF9500;
  --risk-high: #FF3B30;

  /* Spacing (comfortable default) */
  --row-h: 40px;
  --row-h-compact: 30px;
  --pad: 12px;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  --shadow-1: 0 1px 2px rgba(0,0,0,0.04), 0 1px 1px rgba(0,0,0,0.03);
  --shadow-2: 0 8px 24px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.04);
  --shadow-3: 0 20px 48px rgba(0,0,0,0.16), 0 8px 16px rgba(0,0,0,0.08);

  /* Brand — AOX wordmark. Charcoal on light, silver on dark. */
  --logo-color: #0F0F0F;
  --brand-fg: var(--logo-color);  /* legacy alias */
}

[data-theme="dark"] {
  --bg: #000000;
  --bg-elev: rgba(28,28,30,0.72);
  --bg-solid: #1c1c1e;
  --surface: #1c1c1e;
  --surface-2: #2c2c2e;
  --fg: #f5f5f7;
  --fg-2: #d1d1d6;
  --fg-muted: #98989f;
  --fg-subtle: #6e6e73;
  --border: rgba(255,255,255,0.10);
  --border-strong: rgba(255,255,255,0.18);
  --divider: rgba(255,255,255,0.08);
  --hover: rgba(255,255,255,0.06);
  --selected: rgba(10,132,255,0.20);
  --accent: #0A84FF;
  --accent-soft: rgba(10,132,255,0.22);

  --phase1: #FF9F0A;
  --phase2: #BF5AF2;
  --phase3: #0A84FF;
  --phase4: #30D158;

  --status-notstarted: #8E8E93;
  --status-inprogress: #0A84FF;
  --status-blocked: #FF453A;
  --status-done: #30D158;

  --shadow-1: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-2: 0 8px 24px rgba(0,0,0,0.5);
  --shadow-3: 0 20px 48px rgba(0,0,0,0.6);

  --logo-color: #EAEAEA;  /* silver */
  --brand-fg: var(--logo-color);
}

[data-density="compact"] {
  --row-h: 30px;
  --pad: 8px;
}

* { box-sizing: border-box; }
html, body { margin:0; padding:0; height:100%; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01","cv11";
  letter-spacing: -0.003em;
  overflow: hidden;
}
button, input, textarea, select { font-family: inherit; color: inherit; }
input, textarea, select { outline: none; }
button { cursor: pointer; border: none; background: none; padding: 0; }

/* App shell */
.app {
  display: grid;
  grid-template-rows: auto auto 1fr;
  height: 100vh;
  overflow: hidden;
}

/* Top bar — Apple-style toolbar */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 20;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  min-width: 240px;
}
.brand-mark {
  display: flex; align-items: center;
  color: var(--logo-color);
  line-height: 0;
}

/* === AOX wordmark — PNG asset (see assets/aox-logo-*.png) === */
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-title { font-weight: 600; font-size: 13.5px; letter-spacing: -0.01em; }
.brand-sub { font-size: 11px; color: var(--fg-muted); }

/* Segment control — Apple style */
.segment {
  display: inline-flex;
  padding: 2px;
  background: var(--surface-2);
  border-radius: 9px;
  border: 1px solid var(--border);
  gap: 0;
}
[data-theme="dark"] .segment { background: rgba(120,120,128,0.24); border-color: transparent; }
.segment-item {
  padding: 5px 11px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--fg-2);
  border-radius: 7px;
  letter-spacing: -0.005em;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
  white-space: nowrap;
}
.segment-item:hover { color: var(--fg); }
.segment-item.active {
  background: var(--surface);
  color: var(--fg);
  box-shadow: 0 0 0 0.5px rgba(0,0,0,0.04), 0 1px 3px rgba(0,0,0,0.06);
}
[data-theme="dark"] .segment-item.active { background: #636366; color: #fff; box-shadow: none; }

.spacer { flex: 1; }

/* Icon button */
.iconbtn {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 8px;
  color: var(--fg-2);
  transition: background .15s;
}
.iconbtn:hover { background: var(--hover); color: var(--fg); }
.iconbtn.active { background: var(--accent-soft); color: var(--accent); }

/* Primary button */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { background: var(--hover); }
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: transparent;
}
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-ghost { background: transparent; border-color: transparent; }

/* Search */
.search {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  width: 200px;
}
.search input {
  flex: 1; border: none; background: transparent;
  font-size: 12.5px; color: var(--fg);
}
.search svg { color: var(--fg-muted); flex: none; }

/* Secondary bar — filters, counts */
.subbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--fg-muted);
  overflow-x: auto;
  scrollbar-width: none;
}
.subbar::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--fg-2);
  white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.chip:hover { background: var(--hover); }
.chip.active { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chip-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: currentColor;
}

/* Main content area */
.main {
  position: relative;
  overflow: hidden;
  background: var(--bg);
}
.view {
  position: absolute; inset: 0;
  overflow: auto;
  padding: 18px;
}
.view.view-gantt { padding: 0; }
.view.view-kanban { padding: 18px; }

/* Pill status indicators */
.status-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  background: var(--surface-2);
  color: var(--fg-2);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.status-pill .dot { width: 6px; height: 6px; border-radius: 50%; }
.status-pill.s-not-started { color: var(--fg-muted); }
.status-pill.s-not-started .dot { background: var(--status-notstarted); }
.status-pill.s-in-progress { color: var(--status-inprogress); background: var(--accent-soft); border-color: transparent; }
.status-pill.s-in-progress .dot { background: var(--status-inprogress); }
.status-pill.s-blocked { color: var(--status-blocked); background: rgba(255,69,58,0.12); border-color: transparent; }
.status-pill.s-blocked .dot { background: var(--status-blocked); }
.status-pill.s-done { color: var(--status-done); background: rgba(52,199,89,0.12); border-color: transparent; }
.status-pill.s-done .dot { background: var(--status-done); }

/* Risk pill */
.risk {
  display: inline-flex; align-items: center;
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.risk-low { color: var(--risk-low); background: rgba(52,199,89,0.14); }
.risk-med { color: var(--risk-med); background: rgba(255,149,0,0.14); }
.risk-high { color: var(--risk-high); background: rgba(255,59,48,0.14); }

/* Progress */
.progress-bar { height: 4px; background: var(--surface-2); border-radius: 2px; overflow: hidden; border: 1px solid var(--border); }
.progress-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width .25s ease; }
.progress-fill.done { background: var(--status-done); }

/* Avatar */
.avatar {
  width: 22px; height: 22px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: #fff;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: -0.02em;
  flex: none;
  box-shadow: 0 0 0 1.5px var(--surface);
}
.avatar-stack { display: flex; }
.avatar-stack .avatar + .avatar { margin-left: -6px; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.28);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  display: grid; place-items: center;
  animation: fadein .2s ease;
}
.modal {
  width: min(680px, 92vw);
  max-height: 86vh;
  overflow: auto;
  background: var(--bg-solid);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3);
  border: 1px solid var(--border);
  animation: modalin .25s cubic-bezier(.3,.8,.3,1);
}
.modal header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--divider);
  position: sticky; top:0; background: var(--bg-solid); z-index: 2;
}
.modal h2 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.modal .body { padding: 18px 20px; }
.modal .field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.modal .field label { font-size: 11px; font-weight: 500; color: var(--fg-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.modal .field input, .modal .field select, .modal .field textarea {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
}
.modal .field input:focus, .modal .field select:focus, .modal .field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Tweaks panel */
.tweaks-panel {
  position: fixed;
  bottom: 20px; right: 20px;
  width: 300px;
  background: var(--bg-elev);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3);
  z-index: 50;
  overflow: hidden;
  animation: modalin .22s cubic-bezier(.3,.8,.3,1);
}
.tweaks-panel header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px 8px;
  border-bottom: 1px solid var(--divider);
}
.tweaks-panel header h3 {
  margin: 0; font-size: 13px; font-weight: 600; letter-spacing: -0.01em;
}
.tweaks-panel .body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 14px; }
.tweak-row { display: flex; flex-direction: column; gap: 6px; }
.tweak-row > label {
  font-size: 10.5px; font-weight: 600; color: var(--fg-muted);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.tweak-row .seg { display: flex; gap: 0; padding: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; }
[data-theme="dark"] .tweak-row .seg { background: rgba(120,120,128,0.24); border-color: transparent; }
.tweak-row .seg button {
  flex: 1;
  padding: 5px 8px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--fg-2);
  border-radius: 6px;
  transition: all .15s;
}
.tweak-row .seg button.active { background: var(--surface); color: var(--fg); box-shadow: 0 1px 2px rgba(0,0,0,0.06); }
[data-theme="dark"] .tweak-row .seg button.active { background: #636366; color: #fff; }

.swatch-row { display: flex; gap: 8px; }
.swatch {
  flex: 1;
  height: 28px;
  border-radius: 7px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform .1s;
  position: relative;
}
.swatch:hover { transform: scale(1.05); }
.swatch.active { border-color: var(--fg); box-shadow: 0 0 0 2px var(--bg-solid); }

/* Sheet connection panel */
.sheet-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--fg-2);
}
.sheet-pill .led { width: 7px; height: 7px; border-radius: 50%; background: var(--status-notstarted); }
.sheet-pill.connected .led { background: var(--status-done); box-shadow: 0 0 8px rgba(52,199,89,0.6); }

/* Animations */
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalin {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.28); background-clip: padding-box; border: 2px solid transparent; }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); background-clip: padding-box; border: 2px solid transparent; }

/* Toast */
.toast {
  position: fixed;
  top: 60px; left: 50%;
  transform: translateX(-50%);
  padding: 10px 16px;
  background: var(--bg-solid);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow-2);
  font-size: 12.5px;
  font-weight: 500;
  z-index: 200;
  animation: toastin .25s cubic-bezier(.3,.8,.3,1);
}
@keyframes toastin {
  from { opacity: 0; transform: translateX(-50%) translateY(-8px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

/* utility */
.mono { font-family: var(--font-mono); font-size: 11.5px; }
.muted { color: var(--fg-muted); }
.num-tab { font-variant-numeric: tabular-nums; }

/* Inline "+ Add task" button on Gantt group headers. Fades in on row hover;
   always visible on touch devices so it's reachable without a hover state. */
.group-header-row .group-add-btn {
  opacity: 0;
  width: 22px; height: 22px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-solid);
  color: var(--fg-muted);
  cursor: pointer;
  font-size: 14px; line-height: 1;
  padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  transition: opacity 120ms ease, background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.group-header-row:hover .group-add-btn { opacity: 1; }
.group-header-row .group-add-btn:hover {
  color: var(--fg);
  background: var(--hover);
  border-color: var(--border-strong);
}
@media (hover: none) { .group-header-row .group-add-btn { opacity: 1; width: 32px; height: 32px; } }

@keyframes aox-toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Row flash when a task was just created via the group-header + button. */
.aox-just-added { animation: aox-row-flash 450ms ease-out 1; }
@keyframes aox-row-flash {
  0%   { background: var(--accent-soft); }
  100% { background: transparent; }
}
@media (prefers-reduced-motion: reduce) {
  .aox-just-added { animation: none; }
}

/* RollingNumber final-frame bounce — "착!" moment when the digit locks. */
.rolling-bounce { animation: aox-rolling-bounce 200ms cubic-bezier(.34,1.56,.64,1); }
@keyframes aox-rolling-bounce {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.08); }
  100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .rolling-bounce { animation: none; }
}
