:root {
  --bg: #f5f4f0;
  --panel: #ffffff;
  --panel-2: #faf9f6;
  --ink: #1d1d1b;
  --muted: #6b6a65;
  --line: #e3e1da;
  --accent: #2f5d50;
  --accent-ink: #ffffff;
  --accent-soft: #e3eee9;
  --danger: #b3261e;
  --weekend: rgba(0, 0, 0, .035);
  --today: #d9534f;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.05);
  --s-ide: #8a8f98; --s-script: #5b6fd0; --s-syuting: #c9772f; --s-edit: #9d5cc9;
  --s-siap: #2f8f80; --s-terposting: #3f8a3f;
  --s-todo: #8a8f98; --s-jalan: #c28a1e; --s-review: #5b6fd0; --s-selesai: #3f8a3f;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131312; --panel: #1c1c1a; --panel-2: #222220; --ink: #ecebe5; --muted: #a2a09a;
    --line: #2f2e2b; --accent: #82bba7; --accent-ink: #0f1a16; --accent-soft: #1f2d28;
    --danger: #f08a83; --weekend: rgba(255,255,255,.035); --today: #f07c78;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #131312; --panel: #1c1c1a; --panel-2: #222220; --ink: #ecebe5; --muted: #a2a09a;
  --line: #2f2e2b; --accent: #82bba7; --accent-ink: #0f1a16; --accent-soft: #1f2d28;
  --danger: #f08a83; --weekend: rgba(255,255,255,.035); --today: #f07c78;
  --shadow: 0 1px 2px rgba(0,0,0,.4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; width: 100%; min-width: 0;
}
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
label { display: grid; gap: 4px; font-weight: 600; font-size: 13px; }
button {
  cursor: pointer; border: 1px solid var(--line); background: var(--panel);
  border-radius: 8px; padding: 7px 12px; white-space: nowrap;
}
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.primary:hover { filter: brightness(1.08); }
button.ghost { background: transparent; border-color: transparent; }
button.ghost:hover { background: var(--panel-2); border-color: var(--line); }
button.danger { color: var(--danger); }
button.icon { padding: 4px 9px; }
button:disabled { opacity: .55; cursor: default; }
.muted { color: var(--muted); font-weight: 400; }
.error { color: var(--danger); margin: 0; min-height: 1em; font-size: 13px; }
.spacer { flex: 1; }

.brand { font-weight: 800; letter-spacing: -.01em; font-size: 16px; }
.brand span { font-weight: 500; color: var(--muted); margin-left: 6px; }
.brand.big { font-size: 22px; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 28px; display: grid; gap: 14px; box-shadow: var(--shadow);
}
.login-card p { margin: 0; }

/* Shell */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.top {
  display: flex; align-items: center; gap: 16px; padding: 10px 16px;
  background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.tabs { display: flex; gap: 4px; overflow-x: auto; flex: 1; }
.tabs button { background: transparent; border-color: transparent; font-weight: 600; color: var(--muted); }
.tabs button[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.who { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.toolbar {
  display: flex; align-items: center; gap: 8px; padding: 10px 16px; flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
}
.toolbar input[type=search] { width: 220px; }
.toolbar select { width: auto; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--panel); }
.seg button { border: 0; border-radius: 0; padding: 7px 12px; background: transparent; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.view-ctl { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.view-ctl .label { font-weight: 700; min-width: 130px; text-align: center; }
.banner { margin: 10px 16px 0; padding: 10px 12px; border-radius: 8px; background: var(--accent-soft); font-size: 13px; }
.main { flex: 1; padding: 16px; min-height: 0; }

/* Badges */
.badges { display: flex; flex-wrap: wrap; gap: 4px; }
.badge { font-size: 11px; padding: 1px 7px; border-radius: 99px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); }
.badge.late { color: var(--danger); border-color: currentColor; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; background: var(--c, var(--muted)); }

/* Kanban */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.col { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 190px); }
.col-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; font-weight: 700; border-top: 3px solid var(--c); border-radius: var(--radius) var(--radius) 0 0; }
.col-head .count { color: var(--muted); font-weight: 500; }
.col-head button { margin-left: auto; }
.col-list { display: flex; flex-direction: column; gap: 8px; padding: 4px 10px 12px; overflow-y: auto; min-height: 60px; flex: 1; }
.col.over .col-list { background: var(--accent-soft); border-radius: 0 0 var(--radius) var(--radius); }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px;
  display: grid; gap: 6px; cursor: grab; box-shadow: var(--shadow); text-align: left; width: 100%;
}
.card:hover { border-color: var(--muted); }
.card.dragging { opacity: .45; }
.card .t { font-weight: 600; word-break: break-word; }
.card .snip { color: var(--muted); font-size: 12px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.empty { color: var(--muted); font-size: 13px; text-align: center; padding: 18px 8px; }

/* Gantt */
.gantt { --label: 230px; --day: 30px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; max-height: calc(100vh - 190px); position: relative; }
.g-inner { position: relative; width: calc(var(--label) + var(--days) * var(--day)); }
.g-head, .g-row { display: grid; grid-template-columns: var(--label) calc(var(--days) * var(--day)); }
.g-head { position: sticky; top: 0; z-index: 3; background: var(--panel); border-bottom: 1px solid var(--line); }
.g-corner { position: sticky; left: 0; z-index: 4; background: var(--panel); border-right: 1px solid var(--line); padding: 8px 12px; font-weight: 700; display: flex; align-items: end; }
.g-scale { display: grid; grid-template-columns: repeat(var(--days), var(--day)); }
.g-month { grid-row: 1; font-weight: 700; font-size: 12px; padding: 4px 6px; border-left: 1px solid var(--line); white-space: nowrap; overflow: hidden; }
.g-day { grid-row: 2; font-size: 11px; text-align: center; color: var(--muted); padding: 3px 0 5px; }
.g-day.we { background: var(--weekend); }
.g-day.today { color: var(--today); font-weight: 800; }
.g-bg { position: absolute; top: 0; bottom: 0; left: var(--label); display: grid; grid-template-columns: repeat(var(--days), var(--day)); pointer-events: none; z-index: 0; }
.g-bg div { border-left: 1px solid var(--line); opacity: .5; }
.g-bg .we { background: var(--weekend); opacity: 1; }
.g-bg .today { border-left: 2px solid var(--today); opacity: 1; }
.g-row { position: relative; z-index: 1; border-bottom: 1px solid var(--line); min-height: 38px; }
.g-label { position: sticky; left: 0; z-index: 2; background: var(--panel); border-right: 1px solid var(--line); padding: 8px 12px; display: flex; align-items: center; gap: 8px; min-width: 0; cursor: pointer; }
.g-label span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-label:hover span:last-child { text-decoration: underline; }
.g-track { position: relative; }
.bar {
  position: absolute; top: 7px; height: 24px; border-radius: 6px; background: var(--c); color: #fff;
  font-size: 12px; font-weight: 600; padding: 3px 10px 3px 8px; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; cursor: grab; touch-action: none; user-select: none; box-shadow: var(--shadow);
}
.bar.clip-l { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.bar.clip-r { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.bar .h { position: absolute; right: 0; top: 0; bottom: 0; width: 9px; cursor: ew-resize; background: rgba(255,255,255,.25); }
.bar.dragging { cursor: grabbing; opacity: .85; }
.g-foot { padding: 10px 12px; color: var(--muted); font-size: 12px; }

/* Calendar */
.cal { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.cal-head, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-head div { padding: 8px; font-size: 12px; font-weight: 700; color: var(--muted); border-bottom: 1px solid var(--line); }
.cal-cell { min-height: 108px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 4px; display: flex; flex-direction: column; gap: 3px; cursor: pointer; min-width: 0; }
.cal-cell:nth-child(7n) { border-right: 0; }
.cal-cell.out { background: var(--panel-2); }
.cal-cell.out .num { opacity: .45; }
.cal-cell.we { background: var(--weekend); }
.cal-cell .num { font-size: 12px; font-weight: 600; padding: 2px 4px; align-self: flex-start; border-radius: 99px; }
.cal-cell.today .num { background: var(--today); color: #fff; }
.chip-item {
  display: flex; align-items: center; gap: 5px; font-size: 12px; padding: 2px 6px; border-radius: 5px;
  background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--c);
  text-align: left; width: 100%; min-width: 0;
}
.chip-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Notes */
.notes { display: grid; grid-template-columns: 300px 1fr; gap: 12px; height: calc(100vh - 160px); min-height: 420px; }
.n-list { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 0; }
.n-list .n-tools { padding: 10px; display: flex; gap: 6px; border-bottom: 1px solid var(--line); }
.n-items { overflow-y: auto; flex: 1; }
.n-item { display: grid; gap: 2px; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 10px 12px; background: transparent; }
.n-item[aria-current="true"] { background: var(--accent-soft); }
.n-item .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.n-item .s { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.n-edit { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 0; }
.n-edit .n-bar { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.n-edit .n-title { border: 0; font-size: 20px; font-weight: 700; padding: 14px 16px 6px; background: transparent; }
.n-edit textarea { border: 0; flex: 1; padding: 6px 16px 16px; resize: none; background: transparent; font-size: 15px; line-height: 1.6; }
.n-edit input:focus, .n-edit textarea:focus { outline: none; }
.n-status { color: var(--muted); font-size: 12px; margin-left: auto; }
.n-back { display: none; }

/* Dialog */
.dlg { border: 1px solid var(--line); border-radius: 14px; padding: 0; width: min(640px, calc(100vw - 32px)); background: var(--panel); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.dlg::backdrop { background: rgba(0,0,0,.4); }
.dlg form { display: flex; flex-direction: column; max-height: calc(100vh - 48px); }
.dlg-head, .dlg-foot { display: flex; align-items: center; gap: 8px; padding: 12px 16px; }
.dlg-head { border-bottom: 1px solid var(--line); }
.dlg-head h2 { margin: 0; font-size: 17px; flex: 1; }
.dlg-foot { border-top: 1px solid var(--line); }
.dlg-body { padding: 16px; display: grid; gap: 12px; overflow-y: auto; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.row3.task-mode { grid-template-columns: 1fr 1fr; }
fieldset.plats { border: 0; padding: 0; margin: 0; }
fieldset.plats legend { font-weight: 600; font-size: 13px; padding: 0; margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips label { display: inline-flex; align-items: center; gap: 0; font-weight: 500; }
.chips input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chips span { border: 1px solid var(--line); border-radius: 99px; padding: 4px 11px; cursor: pointer; font-size: 13px; }
.chips input:checked + span { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chips input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--ink); color: var(--bg); padding: 9px 14px; border-radius: 8px; font-size: 13px;
  transition: .2s; pointer-events: none; max-width: calc(100vw - 32px); z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%); }

@media (max-width: 760px) {
  .top { gap: 8px; }
  .tabs { order: 3; flex-basis: 100%; }
  .who #who { display: none; }
  .who { margin-left: auto; }
  .toolbar input[type=search] { width: auto; flex: 1 1 140px; }
  .view-ctl { margin-left: 0; width: 100%; justify-content: space-between; }
  .view-ctl .label { min-width: 0; }
  .main { padding: 12px; }
  .kanban { grid-auto-columns: 82vw; scroll-snap-type: x mandatory; }
  .col { scroll-snap-align: start; max-height: none; }
  .gantt { --label: 130px; --day: 26px; }
  .cal-cell { min-height: 70px; padding: 2px; }
  .chip-item { padding: 1px 3px; font-size: 10px; gap: 3px; }
  .chip-item .dot { display: none; }
  .cal-head div { padding: 6px 2px; text-align: center; }
  .notes { grid-template-columns: 1fr; height: auto; }
  .notes.editing .n-list { display: none; }
  .notes:not(.editing) .n-edit { display: none; }
  .n-back { display: inline-block; }
  .n-edit textarea { min-height: 55vh; }
  .row3, .row3.task-mode { grid-template-columns: 1fr 1fr; }
}
