:root {
  --bg: #0f1115;
  --bg2: #161921;
  --card: #1b1f29;
  --card2: #232837;
  --line: rgba(255,255,255,.07);
  --text: #eef0f5;
  --muted: #8b92a5;
  --faint: #5d6476;
  --accent: #7c8cff;
  --green: #4cd18a;
  --blue: #4bb5ff;
  --amber: #ffb547;
  --red: #ff6b6b;
  --pink: #ff7ac6;
  --violet: #a98bff;
  --radius: 20px;
  --gap: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 600px at 10% -10%, #1d2340 0%, transparent 60%),
              radial-gradient(900px 500px at 110% 10%, #2a1d3a 0%, transparent 55%), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Inter, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
}
input, textarea, select, button { font: inherit; color: inherit; }
input, textarea, [contenteditable] { -webkit-user-select: text; user-select: text; }
.hidden { display: none !important; }
button { cursor: pointer; }

/* ---------- кнопки ---------- */
.btn { border: 0; border-radius: 12px; padding: 9px 14px; background: var(--card2); color: var(--text); font-weight: 600; transition: transform .12s, background .2s, opacity .2s; }
.btn:active { transform: scale(.96); }
.btn.primary { background: var(--accent); color: #0b0d14; }
.btn.ghost { background: rgba(255,255,255,.06); }
.btn.danger { background: rgba(255,107,107,.14); color: var(--red); }
.btn.icon { width: 38px; height: 38px; padding: 0; display: inline-grid; place-items: center; background: rgba(255,255,255,.06); }
.btn.small { padding: 6px 10px; font-size: 13px; border-radius: 10px; }
.round { width: 44px; height: 44px; border-radius: 50%; border: 0; display: inline-grid; place-items: center; font-size: 22px; font-weight: 700; background: var(--card2); color: var(--text); }
.round:active { transform: scale(.92); }

/* ---------- вход ---------- */
.login { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 340px; text-align: center; }
.logo { font-size: 44px; font-weight: 800; letter-spacing: -1px; background: linear-gradient(90deg, #8ea0ff, #ff8bd1); -webkit-background-clip: text; background-clip: text; color: transparent; }
.login-card p { color: var(--muted); margin: 4px 0 24px; }
.login-card input { width: 100%; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); outline: none; font-size: 17px; margin-bottom: 12px; }
.login-card input:focus { border-color: var(--accent); }
.login-card .btn { width: 100%; padding: 14px; font-size: 16px; }
.err { color: var(--red); min-height: 22px; margin-top: 10px; font-size: 14px; }

/* ---------- шапка ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: calc(14px + var(--safe-top)) 18px 10px; max-width: 1400px; margin: 0 auto; }
.hello-title { font-size: 24px; font-weight: 800; letter-spacing: -.4px; }
.hello-sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); margin-right: 4px; transition: background .3s; }
.sync-dot.ok { background: var(--green); }
.sync-dot.busy { background: var(--amber); }
.sync-dot.off { background: var(--red); }
.only-edit { display: none; }
body.editing .only-edit { display: inline-block; }
body.editing #editBtn { background: var(--accent); color: #0b0d14; }

/* ---------- доска ---------- */
.board { position: relative; max-width: 1400px; margin: 0 auto; padding: 0 18px calc(40px + var(--safe-bottom)); }
.board-inner { position: relative; }
.w {
  position: absolute; border-radius: var(--radius); background: var(--card);
  border: 1px solid var(--line); overflow: hidden; display: flex; flex-direction: column;
  transition: left .18s ease, top .18s ease, width .18s ease, height .18s ease, box-shadow .2s, transform .15s;
  box-shadow: 0 6px 24px rgba(0,0,0,.25);
}
.w:active:not(.dragging) { transform: scale(.99); }
.w-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px 4px; font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.w-head .dot { width: 8px; height: 8px; border-radius: 50%; }
.w-head .grow { flex: 1; }
.w-body { flex: 1; min-height: 0; padding: 4px 14px 12px; overflow: hidden; position: relative; }
.w-tools { display: none; }
body.editing .w { cursor: grab; animation: wobble .28s ease-in-out infinite alternate; }
body.editing .w:nth-child(2n) { animation-delay: .14s; }
body.editing .w .w-body { pointer-events: none; }
body.editing .w-tools { display: block; }
@keyframes wobble { from { transform: rotate(-.35deg); } to { transform: rotate(.35deg); } }
.w.dragging { z-index: 50; transition: none; animation: none !important; box-shadow: 0 20px 60px rgba(0,0,0,.5); cursor: grabbing; opacity: .95; }
.w-del { position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(255,107,107,.9); color: #fff; font-weight: 800; font-size: 15px; line-height: 26px; z-index: 3; }
.w-resize { position: absolute; right: 0; bottom: 0; width: 34px; height: 34px; z-index: 3; cursor: nwse-resize; touch-action: none; }
.w-resize::after { content: ''; position: absolute; right: 9px; bottom: 9px; width: 12px; height: 12px; border-right: 3px solid var(--muted); border-bottom: 3px solid var(--muted); border-radius: 0 0 4px 0; }
.ghost-slot { position: absolute; border-radius: var(--radius); border: 2px dashed rgba(124,140,255,.6); background: rgba(124,140,255,.08); pointer-events: none; transition: all .1s; }

/* ---------- содержимое виджетов ---------- */
.clock-time { font-size: 54px; font-weight: 800; letter-spacing: -2px; line-height: 1; font-variant-numeric: tabular-nums; }
.clock-date { color: var(--muted); margin-top: 4px; }
.clock-bar { height: 6px; border-radius: 3px; background: rgba(255,255,255,.07); margin-top: 8px; overflow: hidden; }
.clock-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--pink)); border-radius: 3px; }
.clock-cap { font-size: 12px; color: var(--faint); margin-top: 6px; }

.tlist { list-style: none; margin: 0; padding: 0; }
.trow { display: flex; align-items: flex-start; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.trow:last-child { border-bottom: 0; }
.chk { flex: none; width: 22px; height: 22px; border-radius: 7px; border: 2px solid var(--faint); background: transparent; display: grid; place-items: center; padding: 0; margin-top: 1px; transition: all .15s; }
.chk.on { background: var(--green); border-color: var(--green); }
.chk.on::after { content: ''; width: 10px; height: 6px; border-left: 2.5px solid #0b0d14; border-bottom: 2.5px solid #0b0d14; transform: rotate(-45deg) translate(1px,-1px); }
.chk.p1 { border-color: var(--blue); } .chk.p2 { border-color: var(--amber); } .chk.p3 { border-color: var(--red); }
.ttext { flex: 1; min-width: 0; }
.ttitle { word-break: break-word; }
.trow.done .ttitle { color: var(--faint); text-decoration: line-through; }
.tmeta { font-size: 12px; color: var(--muted); margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; }
.tmeta .late { color: var(--red); }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 1px 8px; border-radius: 999px; background: rgba(255,255,255,.06); color: var(--muted); }
.empty { color: var(--faint); padding: 10px 0; font-size: 14px; }
.count-badge { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: none; letter-spacing: 0; }

.water-wrap { display: flex; align-items: center; gap: 14px; height: 100%; }
.water-num { font-size: 38px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.water-num small { font-size: 16px; color: var(--muted); font-weight: 600; }
.water-cap { color: var(--muted); font-size: 13px; margin-top: 4px; }
.water-plus { background: var(--blue); color: #04121e; flex: none; width: 52px; height: 52px; font-size: 28px; }
.ring { flex: none; }
.ring circle { fill: none; stroke-width: 8; }
.ring .bg { stroke: rgba(255,255,255,.08); }
.ring .fg { stroke-linecap: round; transition: stroke-dashoffset .4s ease; transform: rotate(-90deg); transform-origin: 50% 50%; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: rgba(255,255,255,.04); border-radius: 999px; padding: 7px 12px; font-size: 14px; display: inline-flex; gap: 6px; align-items: center; transition: all .15s; }
.chip.on { background: rgba(76,209,138,.16); border-color: rgba(76,209,138,.5); color: #bff3d6; }

.focus-wrap { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; gap: 8px; }
.focus-time { font-size: 40px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -1px; }
.focus-mode { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.focus-wrap.compact { gap: 6px; justify-content: flex-start; padding-top: 2px; }
.focus-wrap.compact .focus-time { font-size: 34px; line-height: 1; }

.goal-mini { margin-bottom: 12px; }
.goal-mini-top { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; }
.goal-mini-top span:last-child { color: var(--muted); font-weight: 600; font-size: 13px; }
.bar { height: 7px; border-radius: 4px; background: rgba(255,255,255,.07); margin-top: 6px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 4px; }
.goal-next { font-size: 12px; color: var(--muted); margin-top: 4px; }

.note-prev-title { font-weight: 700; margin-bottom: 4px; }
.note-prev-text { color: var(--muted); white-space: pre-wrap; word-break: break-word; font-size: 14px; }

/* ---------- листы (полные экраны) ---------- */
.sheet-back { position: fixed; inset: 0; background: rgba(5,6,10,.55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 24px; opacity: 0; transition: opacity .2s; }
.sheet-back.show { opacity: 1; }
.sheet { width: 100%; max-width: 760px; max-height: calc(100vh - 48px); background: var(--bg2); border: 1px solid var(--line); border-radius: 24px; display: flex; flex-direction: column; overflow: hidden; transform: translateY(16px) scale(.98); transition: transform .22s ease; box-shadow: 0 30px 80px rgba(0,0,0,.5); }
.sheet-back.show .sheet { transform: none; }
.sheet.narrow { max-width: 460px; }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px 10px; }
.sheet-head h2 { margin: 0; font-size: 21px; flex: 1; letter-spacing: -.3px; }
.sheet-body { overflow: auto; padding: 4px 18px 20px; -webkit-overflow-scrolling: touch; flex: 1; }
.sheet-foot { padding: 12px 18px calc(14px + var(--safe-bottom)); border-top: 1px solid var(--line); display: flex; gap: 10px; }
.sheet-foot .grow { flex: 1; }
@media (max-width: 700px) {
  .sheet-back { padding: 0; align-items: flex-end; }
  .sheet { max-width: none; max-height: calc(100vh - var(--safe-top) - 10px); height: calc(100vh - var(--safe-top) - 10px); border-radius: 22px 22px 0 0; transform: translateY(40px); }
  .sheet.narrow { height: auto; }
  .hello-title { font-size: 21px; }
  .top { padding-left: 14px; padding-right: 14px; }
  .board { padding-left: 12px; padding-right: 12px; }
  #addBtn { padding: 9px 10px; }
}

.tabs { display: flex; gap: 6px; background: rgba(255,255,255,.04); padding: 4px; border-radius: 12px; margin-bottom: 14px; overflow-x: auto; }
.tabs button { flex: 1; border: 0; background: transparent; padding: 8px 10px; border-radius: 9px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.tabs button.on { background: var(--card2); color: var(--text); }

.quick { display: flex; gap: 8px; margin-bottom: 12px; }
.quick input { flex: 1; min-width: 0; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); outline: none; }
.quick input:focus { border-color: var(--accent); }
.hint { font-size: 12px; color: var(--faint); margin: -6px 0 12px; }
.group-title { font-size: 13px; color: var(--muted); font-weight: 700; margin: 16px 0 4px; text-transform: uppercase; letter-spacing: .5px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.field input, .field textarea, .field select { width: 100%; padding: 11px 13px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); outline: none; }
.field textarea { min-height: 90px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button { border: 1px solid var(--line); background: var(--card); padding: 8px 12px; border-radius: 10px; color: var(--muted); font-weight: 600; }
.seg button.on { border-color: var(--accent); color: var(--text); background: rgba(124,140,255,.15); }
.colors { display: flex; gap: 8px; }
.colors button { width: 30px; height: 30px; border-radius: 50%; border: 3px solid transparent; }
.colors button.on { border-color: #fff; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; margin-bottom: 10px; }
.card.click { cursor: pointer; }
.card.click:active { transform: scale(.99); }
.card-top { display: flex; align-items: center; gap: 10px; }
.card-top .grow { flex: 1; min-width: 0; font-weight: 700; font-size: 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.timeline { position: relative; margin: 6px 0 0 10px; padding-left: 20px; border-left: 2px solid var(--line); }
.ms { position: relative; padding: 8px 0 12px; display: flex; gap: 10px; align-items: flex-start; }
.ms::before { content: ''; position: absolute; left: -28px; top: 13px; width: 12px; height: 12px; border-radius: 50%; background: var(--bg2); border: 2px solid var(--faint); }
.ms.done::before { background: var(--green); border-color: var(--green); }
.ms .ttext { cursor: pointer; }

.glass { width: 120px; height: 170px; border: 4px solid rgba(255,255,255,.25); border-top: 0; border-radius: 0 0 22px 22px; position: relative; overflow: hidden; margin: 10px auto; }
.glass i { position: absolute; left: 0; right: 0; bottom: 0; background: linear-gradient(180deg, #63c6ff, #2f86ff); transition: height .5s ease; }
.water-big { text-align: center; }
.water-big .water-num { font-size: 52px; }
.water-ctrls { display: flex; justify-content: center; gap: 16px; margin: 14px 0; }
.water-ctrls .round { width: 56px; height: 56px; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 110px; margin-top: 18px; }
.bars div { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bars i { width: 100%; border-radius: 6px 6px 3px 3px; background: rgba(75,181,255,.5); min-height: 3px; }
.bars i.full { background: var(--blue); }
.bars span { font-size: 10px; color: var(--faint); }

.hrow { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.hrow .emoji { font-size: 22px; width: 30px; text-align: center; }
.hrow .grow { flex: 1; min-width: 0; }
.hdots { display: flex; gap: 5px; }
.hdots button { width: 22px; height: 22px; border-radius: 6px; border: 0; background: rgba(255,255,255,.07); padding: 0; }
.hdots button.on { background: var(--green); }
.hdots button.today { outline: 2px solid rgba(255,255,255,.25); outline-offset: 1px; }
.streak { font-size: 12px; color: var(--amber); }

.focus-big { display: grid; place-items: center; margin: 10px 0; position: relative; }
.focus-big .focus-time { position: absolute; font-size: 56px; }
.focus-btns { display: flex; justify-content: center; gap: 12px; margin: 12px 0 20px; }
.focus-btns .btn { min-width: 110px; padding: 12px 18px; }

.notes-layout { display: grid; grid-template-columns: 220px 1fr; gap: 14px; min-height: 360px; }
.notes-list { border-right: 1px solid var(--line); padding-right: 10px; max-height: 60vh; overflow: auto; }
.nitem { padding: 9px 10px; border-radius: 10px; cursor: pointer; margin-bottom: 4px; }
.nitem.on { background: var(--card2); }
.nitem b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nitem span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.note-edit input { width: 100%; font-size: 20px; font-weight: 700; border: 0; background: transparent; outline: none; padding: 4px 0 8px; }
.note-edit textarea { width: 100%; min-height: 50vh; border: 0; background: transparent; outline: none; resize: none; font-size: 15px; line-height: 1.55; }
@media (max-width: 700px) {
  .notes-layout { grid-template-columns: 1fr; }
  .notes-list { border-right: 0; padding-right: 0; max-height: none; }
  .notes-layout.editing .notes-list { display: none; }
}

.picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.pick { text-align: left; border: 1px solid var(--line); background: var(--card); border-radius: 16px; padding: 14px; }
.pick b { display: block; font-size: 15px; margin: 6px 0 2px; }
.pick span { font-size: 12px; color: var(--muted); }
.pick .ico { font-size: 24px; }

.setrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.setrow .grow { flex: 1; }
.setrow .small { margin-top: 2px; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch i { position: absolute; inset: 0; border-radius: 999px; background: var(--card2); transition: background .2s; }
.switch i::after { content: ''; position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch input:checked + i { background: var(--green); }
.switch input:checked + i::after { transform: translateX(20px); }
.stepper { display: inline-flex; align-items: center; gap: 8px; }
.stepper button { width: 32px; height: 32px; border-radius: 10px; border: 0; background: var(--card2); font-size: 18px; font-weight: 700; }
.stepper b { min-width: 46px; text-align: center; font-variant-numeric: tabular-nums; }
.setrow input[type=time] { padding: 7px 9px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); }

.toast { position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom)); transform: translate(-50%, 30px); background: #2a3042; color: var(--text); padding: 12px 18px; border-radius: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.4); opacity: 0; pointer-events: none; transition: all .25s; z-index: 300; max-width: calc(100vw - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.eye-overlay { position: fixed; inset: 0; z-index: 400; background: rgba(8,10,16,.92); display: grid; place-items: center; text-align: center; padding: 24px; }
.eye-overlay h1 { font-size: 30px; margin: 0 0 8px; }
.eye-overlay .big { font-size: 90px; font-weight: 800; font-variant-numeric: tabular-nums; margin: 10px 0; }
