/* NP Connect Lite — phone first, light only, big touch targets. */
:root {
  color-scheme: light only;
  --bg: #f4f5fa;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --line: #e3e6ee;
  --ink: #101828;
  --ink-2: #475467;
  --ink-3: #667085;
  --brand: #4f46e5;
  --brand-2: #06b6d4;
  --good: #12b76a;
  --good-bg: #ecfdf3;
  --bad: #e5484d;
  --bad-bg: #fef3f2;
  --todo: #dc6803;
  --todo-bg: #fffaeb;
  --work-bg: #eef2ff;
  --rgb: linear-gradient(90deg, #ff2d55, #ff9f0a, #ffd60a, #30d158, #0a84ff, #5e5ce6, #bf5af2, #ff2d55);
  --r: 16px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 14px rgba(16, 24, 40, .06);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.wrap { max-width: 640px; margin: 0 auto; padding: 0 16px; }

/* ---------- top bar ---------- */
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top, 0px));
  background: rgba(255, 255, 255, .92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.logo {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; font-weight: 800; font-size: 13px; letter-spacing: .02em;
}
.brand { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand b { font-size: 16px; }
.brand small { color: var(--ink-3); font-size: 12px; }
.link-chip {
  margin-left: auto; font-size: 12px; font-weight: 600; color: var(--ink-2); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; white-space: nowrap;
}

/* ---------- status card ---------- */
.hero {
  margin: 16px 0 12px; padding: 18px; border-radius: 20px; background: var(--surface); box-shadow: var(--shadow);
  display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; align-items: center; position: relative; overflow: hidden;
}
.hero[data-tone="work"]::before { content: ""; position: absolute; inset: 0 0 auto; height: 4px; background: var(--rgb); background-size: 400px 100%; animation: rgb-flow 3s linear infinite; }
.hero-icon {
  width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: var(--surface-2); color: var(--ink-3);
}
.hero-icon .ico svg { width: 28px; height: 28px; }
.hero-icon[data-tone="good"] { background: var(--good-bg); color: var(--good); }
.hero-icon[data-tone="bad"] { background: var(--bad-bg); color: var(--bad); }
.hero-icon[data-tone="todo"] { background: var(--todo-bg); color: var(--todo); }
.hero-icon[data-tone="work"] { background: var(--work-bg); color: var(--brand); }
.hero-text h1 { margin: 0; font-size: 24px; line-height: 1.2; letter-spacing: -.01em; }
.hero-text p { margin: 2px 0 0; color: var(--ink-2); font-size: 15px; }
.hero > .bar, .hero > .btn, .hero > .os-line, .hero > .small { grid-column: 1 / -1; }
.hero > .btn { margin-top: 6px; min-height: 52px; font-size: 17px; }
.hero-bar { height: 10px; margin-top: 8px; }
.os-line { margin: 8px 0 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; color: var(--ink-2); padding-top: 10px; border-top: 1px solid var(--line); }
.os-line > span:not(.ico) { flex: 1 1 0; min-width: 0; }
.os-line .ico svg { width: 16px; height: 16px; }
.os-line.bad { color: var(--bad); }
.small { margin: 0; font-size: 14px; color: var(--ink-3); }
.linkish { background: none; border: 0; min-height: 44px; padding: 0 6px; display: inline-flex; align-items: center; color: var(--brand); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }

/* ---------- the big button ---------- */
.add {
  width: 100%; min-height: 64px; border: 0; border-radius: 18px; display: flex; align-items: center; justify-content: center; gap: 10px;
  background: linear-gradient(135deg, var(--brand), #3b82f6); color: #fff; font-size: 19px; font-weight: 700;
  box-shadow: 0 6px 18px rgba(79, 70, 229, .28); transition: transform .08s ease, box-shadow .15s ease;
}
.add .ico svg { width: 24px; height: 24px; }
.add:active { transform: scale(.985); box-shadow: 0 3px 10px rgba(79, 70, 229, .25); }
.add:disabled { background: #c9cdd8; box-shadow: none; cursor: default; }
.add:focus-visible { outline: 3px solid #a5b4fc; outline-offset: 3px; }
.hint { margin: 10px 4px 0; font-size: 14px; color: var(--ink-3); }

/* ---------- calculator rows ---------- */
.calcs { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 10px; }
.calc {
  background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden;
  border-left: 5px solid var(--line); transition: border-color .2s ease, opacity .2s ease;
}
.calc.tone-work { border-left-color: var(--brand); }
.calc.tone-good { border-left-color: var(--good); }
.calc.tone-bad { border-left-color: var(--bad); }
.calc.tone-todo { border-left-color: var(--todo); }
.calc.tone-off { opacity: .62; }
.calc-main {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 64px;
  background: none; border: 0; text-align: left;
}
.num {
  width: 32px; height: 32px; border-radius: 10px; flex: none; display: grid; place-items: center;
  background: color-mix(in srgb, var(--m, var(--brand)) 12%, white); color: var(--m, var(--brand)); font-weight: 800; font-size: 14px;
}
.calc-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.calc-name { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.calc-line { font-size: 14px; color: var(--ink-2); }
.tone-bad .calc-line { color: var(--bad); }
.tone-good .calc-line { color: #067647; }
.calc-state { width: 26px; height: 26px; flex: none; border-radius: 50%; position: relative; }
.calc-state[data-tone="good"] { background: var(--good); }
.calc-state[data-tone="good"]::after { content: ""; position: absolute; left: 9px; top: 5px; width: 6px; height: 11px; border: solid #fff; border-width: 0 3px 3px 0; transform: rotate(45deg); }
.calc-state[data-tone="bad"] { background: var(--bad); }
.calc-state[data-tone="bad"]::after { content: "!"; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 16px; }
.calc-state[data-tone="todo"] { background: var(--todo-bg); border: 2px solid var(--todo); }
.calc-state[data-tone="work"] { background: conic-gradient(#ff2d55, #ffd60a, #30d158, #0a84ff, #bf5af2, #ff2d55); animation: spin 1.1s linear infinite; }
.calc-state[data-tone="work"]::after { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: var(--surface); }
.calc-state[data-tone="idle"], .calc-state[data-tone="off"] { border: 2px solid var(--line); }
.calc > .bar { margin: 0 14px 12px; }
.calc-act { padding: 0 14px 12px; }
.calc-act .btn { width: 100%; min-height: 46px; }
.calc-more { padding: 4px 14px 14px; border-top: 1px solid var(--line); }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 10px 0; font-size: 14px; }
.facts dt { color: var(--ink-3); }
.facts dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.name-field { display: grid; gap: 4px; margin: 6px 0 10px; font-size: 13px; color: var(--ink-3); }
.name-field input { min-height: 44px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); color: var(--ink); font-size: 16px; }
.more-acts { display: flex; flex-wrap: wrap; gap: 8px; }
.calc.flash { animation: row-flash .9s ease-out 2; }
@keyframes row-flash { 0% { box-shadow: 0 0 0 0 rgba(79, 70, 229, .0); background: var(--surface); } 30% { box-shadow: 0 0 0 4px rgba(79, 70, 229, .35); background: #eef2ff; } 100% { box-shadow: var(--shadow); background: var(--surface); } }

/* ---------- buttons ---------- */
.btn {
  min-height: 44px; padding: 8px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  font-weight: 600; font-size: 15px; color: var(--ink);
}
.btn:active { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.sm { min-height: 40px; padding: 6px 12px; font-size: 14px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary.danger-fill { background: var(--bad); border-color: var(--bad); }
.tone-bad .calc-act .btn { border-color: #fecdca; color: #b42318; background: var(--bad-bg); }
.tone-todo .calc-act .btn { border-color: #fedf89; color: #93370d; background: var(--todo-bg); }
.ico { display: inline-flex; }
.ico svg { width: 18px; height: 18px; }

/* ---------- progress: RGB breathing bar ---------- */
.bar { height: 8px; border-radius: 999px; background: #eef0f6; position: relative; }
.bar > i { display: block; height: 100%; width: 0; border-radius: inherit; transition: width .3s ease; }
.bar.rgb > i {
  background-image: var(--rgb); background-size: 320px 100%; background-repeat: repeat-x;
  animation: rgb-flow 2.6s linear infinite, rgb-breathe 2.4s ease-in-out infinite;
}
.bar.rgb.indeterminate > i { width: 100% !important; animation: rgb-flow 4s linear infinite, rgb-breathe 3.2s ease-in-out infinite; opacity: .85; }
@keyframes rgb-flow { from { background-position: 0 0; } to { background-position: 320px 0; } }
@keyframes rgb-breathe {
  0%   { box-shadow: 0 0 4px 0 rgba(255, 45, 85, .30); filter: brightness(.92) saturate(1); }
  25%  { box-shadow: 0 0 14px 2px rgba(255, 214, 10, .55); filter: brightness(1.12) saturate(1.3); }
  50%  { box-shadow: 0 0 4px 0 rgba(48, 209, 88, .30); filter: brightness(.92) saturate(1); }
  75%  { box-shadow: 0 0 14px 2px rgba(10, 132, 255, .55); filter: brightness(1.12) saturate(1.3); }
  100% { box-shadow: 0 0 4px 0 rgba(255, 45, 85, .30); filter: brightness(.92) saturate(1); }
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- options ---------- */
.options { margin: 18px 0 0; background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); }
.options > summary {
  list-style: none; min-height: 56px; display: flex; align-items: center; padding: 0 18px; font-weight: 700; font-size: 16px; cursor: pointer;
}
.options > summary::-webkit-details-marker { display: none; }
.options > summary::after { content: ""; margin-left: auto; width: 9px; height: 9px; border: solid var(--ink-3); border-width: 0 2px 2px 0; transform: rotate(45deg); transition: transform .15s ease; }
.options[open] > summary::after { transform: rotate(-135deg); }
#optBody { padding: 0 18px 8px; }
.opt { padding: 14px 0; border-top: 1px solid var(--line); }
.opt h2 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }
.opt-row { display: flex; align-items: center; gap: 14px; padding: 8px 0; }
.opt-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.opt-text small, .opt-note { color: var(--ink-3); font-size: 13px; }
.opt-note { display: block; margin: 6px 0 0; }
p.opt-note { margin: 0 0 8px; color: var(--ink-2); font-size: 14px; }
.opt-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.opt select { min-height: 44px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); padding: 6px 10px; max-width: 48%; }
.help { margin: 0; padding-left: 20px; color: var(--ink-2); font-size: 14px; display: grid; gap: 6px; }
.log { list-style: none; margin: 0; padding: 0; font-size: 12px; color: var(--ink-2); display: grid; gap: 4px; max-height: 240px; overflow: auto; }
.log li.error { color: var(--bad); }
.log li.warn { color: var(--todo); }
.log time { color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* switch (dom.js toggle) */
.switch { position: relative; display: inline-flex; align-items: center; flex: none; }
.switch input { position: absolute; opacity: 0; width: 52px; height: 32px; margin: 0; cursor: pointer; }
.switch-track { width: 52px; height: 32px; border-radius: 999px; background: #d0d5dd; position: relative; transition: background .15s ease; }
.switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(16, 24, 40, .25); transition: transform .15s ease; }
.switch input:checked + .switch-track { background: var(--brand); }
.switch input:checked + .switch-track::after { transform: translateX(20px); }
.switch input:focus-visible + .switch-track { outline: 3px solid #a5b4fc; outline-offset: 2px; }

/* ---------- footer, toasts, dialogs ---------- */
.foot { max-width: 640px; margin: 18px auto 0; padding: 0 16px calc(24px + var(--safe-b)); text-align: center; font-size: 12px; color: var(--ink-3); }
.toast-host {
  position: fixed; inset: auto 0 calc(16px + var(--safe-b)) 0; margin: 0 auto; width: min(560px, calc(100% - 24px));
  border: 0; padding: 0; background: transparent; overflow: visible; display: grid; gap: 8px; z-index: 50;
}
.toast-host:not(:popover-open):empty { display: none; }
.toast { background: #101828; color: #fff; padding: 12px 16px; border-radius: 14px; font-size: 15px; box-shadow: 0 8px 24px rgba(16, 24, 40, .25); }
.toast.err { background: #b42318; }
dialog.ask { border: 0; border-radius: 18px; padding: 0; width: min(420px, calc(100% - 32px)); box-shadow: 0 20px 50px rgba(16, 24, 40, .3); }
dialog.ask::backdrop { background: rgba(16, 24, 40, .45); }
.dlg-head h2 { margin: 0; padding: 18px 18px 0; font-size: 18px; }
.dlg-body { padding: 10px 18px; color: var(--ink-2); }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 18px 18px; }

@media (min-width: 700px) {
  .hero-text h1 { font-size: 28px; }
}
@media (prefers-reduced-motion: reduce) {
  .bar.rgb > i, .bar.rgb.indeterminate > i, .hero[data-tone="work"]::before, .calc-state[data-tone="work"] { animation: none !important; }
  .calc.flash { animation-duration: .01s; }
}
