:root {
  --bg: #14161c; --panel: #1d2029; --panel2: #262a35; --line: #313644;
  --text: #eef0f5; --muted: #8d93a5; --accent: #7c9cff; --accent2: #5ee1b0;
  --warn: #ffb547; --danger: #ff6b6b; --shift: #3a2f5c;
  --r: 14px; --hour: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif; }
body { overscroll-behavior: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.label { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 14px 0 8px; }
.row { display: flex; align-items: center; } .gap { gap: 8px; } .center { justify-content: center; } .end { justify-content: flex-end; }
.row-between { display: flex; justify-content: space-between; align-items: center; }
.spacer { flex: 1; }
input, select, textarea { width: 100%; background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font: inherit; font-size: 16px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
textarea { resize: vertical; margin-top: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); flex: 1; }
.btn { border: 0; border-radius: 12px; padding: 11px 16px; font: inherit; font-weight: 600; cursor: pointer; color: var(--text); background: var(--panel2); white-space: nowrap; }
.btn.primary { background: var(--accent); color: #0d1020; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.danger { color: var(--danger); border-color: #5a2a2a; }
.btn.small { padding: 6px 12px; font-size: 14px; }
.btn.big { padding: 14px 30px; font-size: 18px; }
.btn.wide { width: 100%; margin-top: 10px; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; margin-top: 8px; font: inherit; }
.icon-btn { background: none; border: 0; color: var(--text); font-size: 26px; width: 40px; height: 40px; border-radius: 10px; cursor: pointer; }
.icon-btn:active { background: var(--panel2); }

/* login */
.screen { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 340px; text-align: center; }
.login-card .logo { font-size: 54px; color: var(--accent); }
.login-card h1 { margin: 4px 0 24px; }
.login-card form { display: flex; flex-direction: column; gap: 10px; }

/* layout */
#app { min-height: 100vh; padding-bottom: calc(76px + var(--safe-b)); }
.top { position: sticky; top: 0; z-index: 20; display: flex; justify-content: space-between; align-items: center; padding: calc(8px + var(--safe-t)) 10px 8px; background: rgba(20,22,28,.92); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.top-left { display: flex; align-items: center; gap: 2px; }
.title-wrap h2 { margin: 0; font-size: 19px; }
main { max-width: 760px; margin: 0 auto; padding: 0 12px; }
.view { padding-top: 6px; }
.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; display: flex; background: rgba(29,32,41,.96); backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
.tabs button { flex: 1; background: none; border: 0; color: var(--muted); padding: 8px 0 10px; font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; }
.tabs button span { font-size: 20px; }
.tabs button.active { color: var(--accent); }
.fab { position: fixed; right: 18px; bottom: calc(86px + var(--safe-b)); z-index: 31; width: 58px; height: 58px; border-radius: 50%; border: 0; background: var(--accent); color: #0d1020; font-size: 30px; box-shadow: 0 8px 24px rgba(0,0,0,.4); cursor: pointer; }

/* now banner */
.now-banner { position: sticky; top: calc(57px + var(--safe-t)); z-index: 19; margin: 0 auto; max-width: 760px; padding: 10px 14px; background: linear-gradient(90deg, #2b3a74, #263a52); display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; }
.now-banner b { font-size: 15px; }
.now-banner .bar { flex: 1; height: 6px; background: rgba(255,255,255,.15); border-radius: 3px; overflow: hidden; min-width: 50px; }
.now-banner .bar i { display: block; height: 100%; background: var(--accent2); }

/* chips */
.unsched-wrap { margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; min-height: 10px; }
.chip { display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); font-size: 14px; cursor: grab; touch-action: pan-y; user-select: none; -webkit-touch-callout: none; -webkit-user-select: none; max-width: 100%; }
.chip .cdot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.chip.empty { cursor: default; color: var(--muted); border-style: dashed; }
.chip .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* timeline */
.timeline { position: relative; margin-top: 4px; border-top: 1px solid var(--line); }
.hour { position: relative; height: var(--hour); border-bottom: 1px solid #22252f; }
.hour .hl { position: absolute; left: 0; top: -8px; width: 48px; font-size: 11px; color: var(--muted); text-align: right; padding-right: 8px; }
.hour .half { position: absolute; left: 52px; right: 0; top: 50%; border-top: 1px dashed #1f222b; }
.slot-hit { position: absolute; left: 52px; right: 0; }
.shift-block { position: absolute; left: 52px; right: 0; background: repeating-linear-gradient(135deg, rgba(90,70,160,.22) 0 10px, rgba(90,70,160,.12) 10px 20px); border-left: 3px solid #8b6cff; pointer-events: none; }
.shift-block span { position: sticky; top: 120px; display: inline-block; font-size: 12px; color: #b9a6ff; padding: 4px 8px; }
.now-line { position: absolute; left: 44px; right: 0; height: 2px; background: var(--danger); z-index: 5; pointer-events: none; }
.now-line::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }
.block { position: absolute; left: 56px; right: 4px; border-radius: 10px; padding: 5px 10px; font-size: 14px; overflow: hidden; z-index: 4; cursor: pointer; touch-action: pan-y; user-select: none; -webkit-touch-callout: none; -webkit-user-select: none; border-left: 4px solid; background: var(--panel2); box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.block .bt { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.block .bm { font-size: 12px; color: var(--muted); }
.block.done { opacity: .45; } .block.done .bt { text-decoration: line-through; }
.block .chk { position: absolute; right: 6px; top: 5px; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--muted); background: none; color: var(--accent2); font-size: 14px; line-height: 18px; padding: 0; cursor: pointer; }
.block.done .chk { border-color: var(--accent2); }
.block .resize { position: absolute; left: 0; right: 0; bottom: 0; height: 12px; cursor: ns-resize; }
.block.dragging, .chip.dragging { opacity: .85; box-shadow: 0 10px 30px rgba(0,0,0,.5); z-index: 50; }
.ghost-chip { position: fixed; z-index: 100; pointer-events: none; }
.drop-preview { position: absolute; left: 56px; right: 4px; border-radius: 10px; border: 2px dashed var(--accent); background: rgba(124,156,255,.1); z-index: 3; pointer-events: none; font-size: 12px; padding: 4px 8px; color: var(--accent); }

/* calendar */
.cal-head { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; font-size: 12px; color: var(--muted); padding: 6px 0; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-cell { aspect-ratio: 1/1.1; background: var(--panel); border-radius: 10px; padding: 5px; font-size: 13px; position: relative; cursor: pointer; border: 1px solid transparent; display: flex; flex-direction: column; }
.cal-cell.other { opacity: .35; }
.cal-cell.today { border-color: var(--accent); }
.cal-cell.sel { background: var(--panel2); }
.cal-cell.shift { background: linear-gradient(180deg, var(--shift), var(--panel)); }
.cal-cell .moon { position: absolute; right: 5px; top: 4px; font-size: 11px; }
.cal-cell .dots { margin-top: auto; display: flex; flex-wrap: wrap; gap: 2px; }
.cal-cell .dots i { width: 6px; height: 6px; border-radius: 50%; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); padding: 10px 2px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: -1px; }
.shift-dot { background: #8b6cff; } .dot { background: var(--accent); border-radius: 50% !important; }

/* lists */
.task-row { display: flex; align-items: center; gap: 10px; padding: 11px 12px; background: var(--panel); border-radius: 12px; margin-bottom: 6px; cursor: pointer; }
.task-row .chk { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--muted); background: none; color: var(--accent2); padding: 0; flex: none; cursor: pointer; font-size: 14px; }
.task-row.done .chk { border-color: var(--accent2); }
.task-row.done .tt { text-decoration: line-through; color: var(--muted); }
.task-row .tt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-row .tm { font-size: 12px; color: var(--muted); flex: none; }
.prio-1 .tt::after { content: " !"; color: var(--warn); font-weight: 700; }
.prio-2 .tt::after { content: " !!"; color: var(--danger); font-weight: 700; }
.cat { background: var(--panel); border-radius: var(--r); margin-bottom: 10px; overflow: hidden; }
.cat-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; cursor: pointer; }
.cat-head .sw { width: 14px; height: 14px; border-radius: 4px; flex: none; }
.cat-head .nm { flex: 1; font-weight: 700; }
.cat-body { padding: 0 10px 10px; }
.proj { margin: 6px 0 4px; }
.proj-head { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); padding: 6px 4px; cursor: pointer; }
.proj-head .nm { flex: 1; font-weight: 600; color: var(--text); }
.count { font-size: 12px; color: var(--muted); background: var(--panel2); border-radius: 999px; padding: 1px 8px; }
.mini { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 13px; padding: 4px 6px; }
.card { background: var(--panel); border-radius: var(--r); padding: 4px 14px 14px; margin-bottom: 12px; }
.pattern { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; margin: 10px 0; }
.pattern button { border: 1px solid var(--line); background: var(--panel2); color: var(--muted); border-radius: 8px; padding: 8px 0; font-size: 12px; cursor: pointer; }
.pattern button.on { background: #5b45b8; color: #fff; border-color: #8b6cff; }
.pattern button small { display: block; font-size: 10px; opacity: .8; }

/* sheet */
.sheet-bg { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 620px; max-height: 92vh; overflow-y: auto; background: var(--panel); border-radius: 20px 20px 0 0; padding: 8px 16px calc(16px + var(--safe-b)); }
.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 12px; }
.big-input { font-size: 19px; font-weight: 600; padding: 12px; margin-bottom: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.prio { margin-top: 12px; }
.prio button { flex: 1; border: 1px solid var(--line); background: none; color: var(--muted); border-radius: 10px; padding: 8px; font: inherit; font-size: 14px; cursor: pointer; }
.prio button.on[data-p="0"] { background: var(--panel2); color: var(--text); }
.prio button.on[data-p="1"] { background: #4a3a14; color: var(--warn); border-color: var(--warn); }
.prio button.on[data-p="2"] { background: #4a1f1f; color: var(--danger); border-color: var(--danger); }
.steps { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.step { display: flex; align-items: center; gap: 8px; background: var(--panel2); border-radius: 10px; padding: 6px 8px; }
.step .chk { width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--muted); background: none; color: var(--accent2); padding: 0; font-size: 13px; cursor: pointer; flex: none; }
.step.done .chk { border-color: var(--accent2); }
.step.done .st { text-decoration: line-through; color: var(--muted); }
.step .st { flex: 1; min-width: 0; word-break: break-word; }
.sheet-actions { margin-top: 14px; }
.dialog { margin: auto; width: calc(100% - 32px); max-width: 400px; background: var(--panel); border-radius: 18px; padding: 18px; }
.dialog h3 { margin: 0 0 12px; }
.dialog .field { margin-bottom: 10px; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 12px; }
.swatches button { width: 32px; height: 32px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; }
.swatches button.on { border-color: #fff; }

/* focus */
.focus { position: fixed; inset: 0; z-index: 80; background: radial-gradient(circle at 50% 30%, #1f2747, #0e1016 70%); display: flex; flex-direction: column; align-items: center; padding: calc(30px + var(--safe-t)) 20px calc(20px + var(--safe-b)); overflow-y: auto; gap: 14px; }
.focus .close { position: absolute; right: 12px; top: calc(10px + var(--safe-t)); }
.f-mode { letter-spacing: .3em; font-size: 13px; color: var(--accent2); font-weight: 700; margin-top: 10px; }
.focus.break .f-mode { color: var(--warn); }
.f-title { font-size: 22px; font-weight: 700; text-align: center; max-width: 520px; }
.ring-wrap { position: relative; width: min(70vw, 280px); aspect-ratio: 1; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: rgba(255,255,255,.08); stroke-width: 10; }
.ring-fg { fill: none; stroke: var(--accent2); stroke-width: 10; stroke-linecap: round; stroke-dasharray: 565.5; transition: stroke-dashoffset .5s linear; }
.focus.break .ring-fg { stroke: var(--warn); }
.f-time { position: absolute; inset: 0; display: grid; place-items: center; font-size: clamp(44px, 14vw, 64px); font-weight: 300; font-variant-numeric: tabular-nums; }
.f-next { text-align: center; color: var(--muted); max-width: 480px; }
.f-next b { color: var(--text); display: block; font-size: 18px; margin-top: 2px; }
.f-steps { width: 100%; max-width: 480px; }

.toast { position: fixed; left: 50%; bottom: calc(150px + var(--safe-b)); transform: translateX(-50%); background: #2d3343; color: var(--text); padding: 10px 16px; border-radius: 12px; z-index: 120; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.4); max-width: 90vw; display: flex; gap: 12px; align-items: center; }
.toast button { background: none; border: 0; color: var(--accent); font-weight: 700; cursor: pointer; font: inherit; }
.empty-msg { text-align: center; color: var(--muted); padding: 20px; font-size: 14px; }
@media (min-width: 700px) { :root { --hour: 72px; } }
