:root{
  --bg:#0f1419; --surface:#1a2029; --surface-2:#222b36; --border:#2f3a47;
  --text:#e6ecf2; --text-dim:#9aa8b6; --text-mute:#6b7885;
  --focus:#7f77dd; --focus-bg:#2a2650;
  --break:#1d9e75; --break-bg:#0f3a2e;
  --wind:#378add; --wind-bg:#123044;
  --practice:#cf8ad0;
  --accent:#5dcaa5; --warn:#e0a355; --danger:#d9695f;
  --radius:12px;
}
*{box-sizing:border-box; -webkit-tap-highlight-color:transparent;}
html,body{margin:0; padding:0;}
body{
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  background:var(--bg); color:var(--text); line-height:1.5;
  padding:env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  min-height:100vh;
}
.wrap{max-width:660px; margin:0 auto; padding:20px 16px 48px;}
header{display:flex; align-items:center; justify-content:space-between; gap:12px;}
h1{font-size:22px; font-weight:600; margin:0; letter-spacing:-0.02em;}
.ver{font-size:11px; color:var(--text-mute); font-variant-numeric:tabular-nums;}
.tagline{font-size:14px; color:var(--text-dim); margin:2px 0 18px;}

.tabs{display:flex; gap:6px; margin-bottom:18px;}
.tab{
  flex:1; padding:9px 8px; border:1px solid var(--border); background:var(--surface);
  color:var(--text-dim); border-radius:var(--radius); font-size:13px; font-weight:500;
  cursor:pointer; transition:.15s; text-align:center; font-family:inherit;
}
.tab.active{color:var(--text); border-color:var(--accent); background:var(--surface-2);}
.view{display:none;}
.view.active{display:block;}

.group-label{
  font-size:12px; text-transform:uppercase; letter-spacing:.06em; color:var(--text-mute);
  margin:22px 0 10px; font-weight:600; display:flex; justify-content:space-between; align-items:baseline;
}
.group-label .aside{text-transform:none; letter-spacing:0; font-weight:400;}

/* ---- session card ---- */
.session{
  border:1px solid var(--border); border-left-width:3px; border-radius:var(--radius);
  background:var(--surface); padding:16px; display:flex; gap:16px; align-items:center;
}
.session[data-kind=focus]{border-left-color:var(--focus);}
.session[data-kind=break]{border-left-color:var(--break);}
.session[data-kind=practice]{border-left-color:var(--practice);}
.session[data-kind=idle]{border-left-color:var(--border);}
.session.running{background:var(--surface-2); border-color:var(--accent);}
.session.paused{border-color:var(--warn);}
.ring{position:relative; width:76px; height:76px; flex-shrink:0;}
.ring svg{width:76px; height:76px;}
.ring-bg{fill:none; stroke:var(--bg); stroke-width:5;}
.ring-fill{fill:none; stroke:var(--accent); stroke-width:5; stroke-linecap:round; transition:stroke-dashoffset .4s linear;}
.session[data-kind=break] .ring-fill{stroke:var(--break);}
.session[data-kind=practice] .ring-fill{stroke:var(--practice);}
.session.paused .ring-fill{stroke:var(--warn);}
.session[data-kind=idle] .ring-fill{stroke:var(--border);}
.ring-txt{
  position:absolute; inset:0; display:flex; align-items:center; justify-content:center;
  font-size:16px; font-weight:600; font-variant-numeric:tabular-nums; letter-spacing:-.02em;
}
.sess-body{flex:1; min-width:0;}
.sess-kind{font-size:12px; text-transform:uppercase; letter-spacing:.06em; color:var(--text-mute); font-weight:600;}
.sess-title{font-size:16px; font-weight:500; margin:2px 0 8px; overflow-wrap:anywhere;}
.sess-actions{display:flex; gap:8px; flex-wrap:wrap;}

.btn{
  padding:9px 13px; border:1px solid var(--border); background:var(--surface-2); color:var(--text);
  border-radius:var(--radius); font-size:13px; font-weight:500; cursor:pointer; font-family:inherit;
  display:inline-flex; align-items:center; justify-content:center; gap:6px; transition:.12s;
}
.btn:hover{border-color:var(--text-mute);}
.btn:active{transform:scale(.98);}
.btn.primary{border-color:var(--accent); color:var(--accent);}
.btn.danger{border-color:var(--danger); color:var(--danger);}
.btn.wide{flex:1;}
.btn svg{width:14px; height:14px; stroke:currentColor; stroke-width:2; fill:none; stroke-linecap:round; stroke-linejoin:round;}
.btn.fill svg{fill:currentColor; stroke:none;}
.btn:disabled{opacity:.45; cursor:default;}

/* ---- wisdom ---- */
.wisdom{
  border:1px solid var(--border); border-left:3px solid var(--wind); border-radius:var(--radius);
  background:var(--surface); padding:14px 16px; margin-top:10px;
  display:flex; gap:12px; align-items:flex-start;
}
.wisdom p{margin:0; font-size:14px; line-height:1.6; flex:1;}
.wisdom .attr{display:block; color:var(--text-mute); font-size:13px; margin-top:4px;}
.icon-btn{
  flex-shrink:0; width:30px; height:30px; border:1px solid var(--border); background:none; color:var(--text-mute);
  border-radius:9px; cursor:pointer; display:flex; align-items:center; justify-content:center; transition:.12s;
}
.icon-btn:hover{color:var(--text); border-color:var(--text-mute);}
.icon-btn svg{width:15px; height:15px; stroke:currentColor; stroke-width:2; fill:none; stroke-linecap:round; stroke-linejoin:round;}

/* ---- stats ---- */
.stats{display:grid; grid-template-columns:repeat(4,1fr); gap:9px; margin-top:16px;}
.stat{background:var(--surface); border-radius:var(--radius); padding:12px;}
.stat .label{font-size:11px; color:var(--text-dim); margin-bottom:3px;}
.stat .val{font-size:21px; font-weight:600; font-variant-numeric:tabular-nums; letter-spacing:-.02em;}
.stat .val small{font-size:13px; color:var(--text-mute); font-weight:400;}
.bar{height:6px; background:var(--surface-2); border-radius:3px; overflow:hidden; margin-top:12px;}
.bar span{display:block; height:100%; background:var(--accent); width:0; transition:width .4s ease;}

/* ---- tasks ---- */
.add-task{display:flex; gap:8px; margin-bottom:12px;}
input[type=text],input[type=number],input[type=time],select{
  font-family:inherit; font-size:14px; color:var(--text); background:var(--surface);
  border:1px solid var(--border); border-radius:var(--radius); padding:10px 12px; min-width:0;
}
input:focus,select:focus{outline:none; border-color:var(--accent);}
input::placeholder{color:var(--text-mute);}
.add-task input[type=text]{flex:1;}
.add-task input[type=number]{width:72px; text-align:center;}
.add-task input[type=time]{width:auto;}

.task{
  display:flex; align-items:center; gap:12px; padding:11px 13px; border:1px solid var(--border);
  border-radius:var(--radius); margin-bottom:8px; background:var(--surface); transition:.12s;
}
.task.active{border-color:var(--accent); background:var(--surface-2);}
.task.practice{border-left:3px solid var(--practice);}
.task .t-meta .streak{color:var(--practice);}
.task.done{opacity:.55;}
.check{
  width:23px; height:23px; border-radius:7px; border:1.5px solid var(--border); flex-shrink:0;
  display:flex; align-items:center; justify-content:center; cursor:pointer; background:none; padding:0; transition:.12s;
}
.check svg{width:14px; height:14px; stroke:#0f1419; stroke-width:3; fill:none; opacity:0;}
.task.done .check{background:var(--accent); border-color:var(--accent);}
.task.done .check svg{opacity:1;}
.task .t-body{flex:1; min-width:0;}
.task .t-title{font-size:15px; font-weight:500; overflow-wrap:anywhere;}
.task.done .t-title{text-decoration:line-through; color:var(--text-mute);}
.task .t-meta{font-size:12px; color:var(--text-dim); font-variant-numeric:tabular-nums;}
.task .t-meta .over{color:var(--warn);}
.task .t-meta .carry{color:var(--text-mute);}
.t-actions{display:flex; gap:5px; flex-shrink:0;}
.empty{
  border:1px dashed var(--border); border-radius:var(--radius); padding:22px 16px;
  text-align:center; color:var(--text-mute); font-size:14px;
}

/* ---- rituals ---- */
.row{
  display:flex; align-items:center; gap:12px; padding:12px 13px; border:1px solid var(--border);
  border-radius:var(--radius); margin-bottom:8px; background:var(--surface); cursor:pointer;
  transition:.12s; border-left-width:3px; text-align:left; width:100%; font-family:inherit; color:inherit;
}
.row[data-phase=focus]{border-left-color:var(--focus);}
.row[data-phase=break]{border-left-color:var(--break);}
.row[data-phase=winddown]{border-left-color:var(--wind);}
.row.done{opacity:.6;}
.row.done .check{background:var(--accent); border-color:var(--accent);}
.row.done .check svg{opacity:1;}
.ico{width:21px; height:21px; flex-shrink:0; color:var(--text-dim);}
.ico svg{width:100%; height:100%; stroke:currentColor; stroke-width:1.8; fill:none; stroke-linecap:round; stroke-linejoin:round;}
.row .t-body{flex:1; min-width:0;}
.row .r-t{font-size:15px; font-weight:500;}
.row.done .r-t{text-decoration:line-through; color:var(--text-mute);}
.row .r-d{font-size:13px; color:var(--text-dim);}

/* ---- history chart ---- */
.chart{display:flex; align-items:flex-end; gap:5px; height:120px; padding:12px; background:var(--surface); border-radius:var(--radius);}
.chart .col{flex:1; display:flex; flex-direction:column; justify-content:flex-end; height:100%; gap:4px; min-width:0;}
.chart .col i{display:block; background:var(--accent); border-radius:3px 3px 0 0; min-height:2px; transition:height .3s;}
.chart .col i.today{background:var(--wind);}
.chart .col b{font-size:9px; color:var(--text-mute); text-align:center; font-weight:400; overflow:hidden;}
.legend{display:flex; gap:14px; font-size:12px; color:var(--text-mute); margin-top:8px; justify-content:center;}
.legend i{display:inline-block; width:9px; height:9px; border-radius:2px; margin-right:5px; vertical-align:baseline;}

/* ---- settings ---- */
.setting{
  display:flex; align-items:center; gap:12px; padding:11px 13px; border:1px solid var(--border);
  border-radius:var(--radius); margin-bottom:8px; background:var(--surface);
}
.setting .s-body{flex:1; min-width:0;}
.setting .s-t{font-size:14px; font-weight:500;}
.setting .s-d{font-size:12px; color:var(--text-dim);}
.setting input[type=number]{width:70px; text-align:center; padding:7px;}
.setting input[type=text]{flex:1; min-width:80px; padding:7px 10px;}
.setting.practice-row{gap:8px; flex-wrap:wrap;}
.setting input[type=time]{padding:7px 9px;}
.switch{
  position:relative; width:42px; height:24px; flex-shrink:0; border-radius:12px; background:var(--surface-2);
  border:1px solid var(--border); cursor:pointer; transition:.15s; padding:0;
}
.switch::after{
  content:''; position:absolute; top:2px; left:2px; width:18px; height:18px; border-radius:50%;
  background:var(--text-mute); transition:.15s;
}
.switch[aria-checked=true]{background:var(--break-bg); border-color:var(--accent);}
.switch[aria-checked=true]::after{transform:translateX(18px); background:var(--accent);}

.banner{
  border:1px solid var(--warn); background:var(--surface); border-radius:var(--radius);
  padding:13px 15px; margin-bottom:16px; font-size:13px; color:var(--text-dim);
  display:flex; gap:12px; align-items:center;
}
.banner b{color:var(--text);}
.banner .btn{flex-shrink:0;}
.note{font-size:12px; color:var(--text-mute); line-height:1.7; margin-top:18px;}
.note a{color:var(--text-dim);}

.toast{
  position:fixed; left:50%; bottom:calc(24px + env(safe-area-inset-bottom)); transform:translateX(-50%) translateY(20px);
  background:var(--surface-2); border:1px solid var(--border); color:var(--text); padding:10px 18px;
  border-radius:24px; font-size:13px; opacity:0; pointer-events:none; transition:.25s; z-index:50; max-width:90vw;
}
.toast.show{opacity:1; transform:translateX(-50%) translateY(0);}

@media (max-width:480px){
  .stats{grid-template-columns:1fr 1fr;}
  .session{flex-direction:column; align-items:stretch;}
  .ring{align-self:center;}
}

/* ---- account: avatar + menu ---- */
.head-right{display:flex; align-items:center; gap:12px;}
.avatar-wrap{position:relative;}
.avatar{
  width:34px; height:34px; border-radius:50%; border:1px solid var(--border);
  background:var(--surface-2); color:var(--text); font-family:inherit; font-size:12px;
  font-weight:600; letter-spacing:.02em; cursor:pointer; transition:.12s; padding:0;
  display:flex; align-items:center; justify-content:center;
}
.avatar:hover{border-color:var(--accent); color:var(--accent);}
.avatar[aria-expanded=true]{border-color:var(--accent); color:var(--accent);}
.menu{
  position:absolute; top:calc(100% + 8px); right:0; min-width:230px; z-index:40;
  background:var(--surface-2); border:1px solid var(--border); border-radius:var(--radius);
  padding:6px; box-shadow:0 12px 28px rgba(0,0,0,.45);
}
.menu-head{padding:9px 10px 10px; border-bottom:1px solid var(--border); margin-bottom:6px;}
.menu-email{font-size:13px; font-weight:500; overflow-wrap:anywhere;}
.menu-sub{font-size:11px; color:var(--text-mute); margin-top:2px;}
.menu-item{
  display:block; width:100%; text-align:left; padding:9px 10px; border:none; background:none;
  color:var(--text); font-family:inherit; font-size:13px; border-radius:8px; cursor:pointer;
}
.menu-item:hover{background:var(--surface);}

/* ---- lock screen ---- */
.lock{
  position:fixed; inset:0; z-index:100; background:var(--bg);
  display:flex; align-items:center; justify-content:center; padding:20px;
}
.lock-card, .modal-card{
  width:100%; max-width:360px; background:var(--surface); border:1px solid var(--border);
  border-radius:var(--radius); padding:26px 24px;
}
.lock-mark{font-size:12px; text-transform:uppercase; letter-spacing:.1em; color:var(--text-mute); font-weight:600;}
.lock-card h2, .modal-card h2{font-size:20px; font-weight:600; margin:8px 0 6px; letter-spacing:-.02em;}
.lock-note{font-size:12px; color:var(--text-mute); line-height:1.6; margin:0 0 18px;}
.field{display:block; margin-bottom:14px;}
.field span{display:block; font-size:12px; color:var(--text-dim); margin-bottom:5px;}
.field input{width:100%; padding:10px 12px;}
input[type=email],input[type=password]{
  font-family:inherit; font-size:14px; color:var(--text); background:var(--bg);
  border:1px solid var(--border); border-radius:var(--radius);
}
input[type=email]:focus,input[type=password]:focus{outline:none; border-color:var(--accent);}
.form-error{
  font-size:12px; color:var(--danger); background:var(--surface-2); border:1px solid var(--danger);
  border-radius:9px; padding:9px 11px; margin-bottom:14px; line-height:1.5;
}

/* ---- modal ---- */
.modal{
  position:fixed; inset:0; z-index:90; background:rgba(8,11,15,.72);
  display:flex; align-items:center; justify-content:center; padding:20px;
}
.modal-actions{display:flex; gap:10px; margin-top:4px;}
.lock-card .btn.wide{width:100%;}

/* An author `display` beats the UA stylesheet's [hidden]{display:none}, so
   overlays that lay themselves out with flex must opt back out explicitly. */
.lock[hidden], .modal[hidden], .menu[hidden]{display:none;}
