:root {
  color-scheme: dark;
  --bg: #0b0d15;
  --panel: rgba(22, 25, 40, 0.88);
  --panel-solid: #161928;
  --panel-soft: #1c2032;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f6f7fb;
  --muted: #9ca3b8;
  --dim: #6e758c;
  --mint: #76edc1;
  --blue: #55c9f3;
  --violet: #9a83f7;
  --coral: #ff829d;
  --danger: #ff6f88;
  --shadow: 0 28px 90px rgba(0, 0, 0, 0.38);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 16% 10%, rgba(71, 99, 175, 0.16), transparent 30rem),
    radial-gradient(circle at 80% 85%, rgba(108, 72, 155, 0.14), transparent 32rem),
    var(--bg);
  overflow-x: hidden;
}

button, input { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }
.ambient { position: fixed; pointer-events: none; filter: blur(2px); opacity: .6; border-radius: 999px; }
.ambient-one { width: 22rem; height: 22rem; top: -12rem; right: -7rem; background: rgba(85, 201, 243, .12); }
.ambient-two { width: 20rem; height: 20rem; bottom: -13rem; left: -8rem; background: rgba(154, 131, 247, .13); }
.screen { min-height: 100vh; position: relative; z-index: 1; }

.login-screen { display: grid; place-items: center; padding: 2rem 1.2rem; }
.login-card {
  width: min(100%, 29rem);
  padding: 3rem;
  text-align: center;
  background: linear-gradient(145deg, rgba(28, 32, 52, .98), rgba(15, 18, 30, .98));
  border: 1px solid var(--line);
  border-radius: 2rem;
  box-shadow: var(--shadow);
}
.brand-mark {
  width: 5rem;
  height: 5rem;
  margin: 0 auto 1.5rem;
  display: grid;
  place-items: center;
  position: relative;
  border-radius: 1.5rem;
  background: linear-gradient(135deg, rgba(118, 237, 193, .16), rgba(154, 131, 247, .2));
  border: 1px solid rgba(118, 237, 193, .2);
  transform: rotate(-4deg);
}
.brand-heart { color: var(--coral); font-size: 2rem; text-shadow: 0 0 24px rgba(255, 130, 157, .4); }
.brand-pad { position: absolute; color: var(--mint); right: .75rem; top: .55rem; font-size: .8rem; }
.eyebrow { margin: 0 0 .6rem; color: var(--mint); font-size: .68rem; font-weight: 800; letter-spacing: .2em; }
h1, h2, p { margin-top: 0; }
.login-card h1 { margin-bottom: .7rem; font-size: clamp(1.8rem, 6vw, 2.35rem); letter-spacing: -.04em; }
.login-copy { color: var(--muted); line-height: 1.75; margin-bottom: 2rem; }
.login-form, .modal form { display: grid; gap: 1rem; text-align: left; }
label { display: grid; gap: .5rem; }
label > span { color: #c9cede; font-size: .82rem; font-weight: 700; }
input {
  width: 100%;
  padding: .9rem 1rem;
  color: var(--text);
  background: rgba(8, 10, 18, .72);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: .9rem;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
input:focus { border-color: rgba(118, 237, 193, .7); box-shadow: 0 0 0 3px rgba(118, 237, 193, .1); }
.form-error { min-height: 1.1rem; margin: -.2rem 0 0; color: #ff9aaa; font-size: .82rem; }
.privacy-note { margin: 1.5rem 0 0; color: var(--dim); font-size: .72rem; }
.privacy-note span { color: var(--mint); font-size: .55rem; margin-right: .25rem; }

.button {
  border: 0;
  border-radius: 1rem;
  cursor: pointer;
  transition: transform .18s, filter .18s, opacity .18s;
}
.button:hover:not(:disabled) { transform: translateY(-2px); filter: brightness(1.06); }
.button:active:not(:disabled) { transform: translateY(0); }
.button:disabled { cursor: not-allowed; opacity: .45; }
.button-primary { padding: .9rem 1.1rem; color: #0b1916; background: linear-gradient(135deg, var(--mint), #50d8d0); font-weight: 800; }
.button-secondary { padding: .9rem 1.1rem; color: var(--text); background: var(--panel-soft); border: 1px solid var(--line); font-weight: 700; }
.login-button { margin-top: .15rem; }

.topbar {
  min-height: 4.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 max(1.2rem, calc((100vw - 72rem) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(11, 13, 21, .72);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: .65rem; color: var(--text); font-weight: 800; text-decoration: none; }
.mini-mark { width: 1.9rem; height: 1.9rem; display: grid; place-items: center; border-radius: .65rem; color: var(--coral); background: rgba(255,130,157,.12); }
.account-area { display: flex; align-items: center; gap: .65rem; color: #d9ddeb; font-size: .8rem; }
.online-dot { width: .45rem; height: .45rem; border-radius: 50%; background: var(--mint); box-shadow: 0 0 10px var(--mint); }
.text-button, .icon-button { border: 0; background: none; cursor: pointer; }
.text-button { padding: .4rem .2rem; color: #c9cfdf; font-size: .78rem; }
.text-button:hover { color: var(--mint); }
.text-button.muted { color: var(--dim); }

.dashboard-shell {
  width: min(72rem, calc(100% - 2.4rem));
  margin: 0 auto;
  padding: 2.4rem 0 4rem;
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(18rem, .9fr);
  gap: 1.2rem;
}
.hero-panel, .card {
  background: linear-gradient(145deg, rgba(25, 29, 47, .94), rgba(17, 20, 33, .92));
  border: 1px solid var(--line);
  box-shadow: 0 16px 45px rgba(0,0,0,.16);
}
.hero-panel { grid-row: span 2; padding: 2rem; border-radius: 1.65rem; }
.card { padding: 1.5rem; border-radius: 1.35rem; }
.hero-heading, .section-heading, .modal-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.hero-heading h1 { margin-bottom: 0; font-size: clamp(1.65rem, 4vw, 2.3rem); letter-spacing: -.04em; }
.status-pill { display: flex; align-items: center; gap: .45rem; padding: .5rem .75rem; border-radius: 999px; color: var(--muted); background: rgba(255,255,255,.04); font-size: .72rem; }
.status-pill span { width: .45rem; height: .45rem; border-radius: 50%; background: var(--dim); }
.status-pill.active { color: #caffed; background: rgba(118,237,193,.1); }
.status-pill.active span { background: var(--mint); box-shadow: 0 0 10px rgba(118,237,193,.8); animation: pulse 1.5s infinite; }
@keyframes pulse { 50% { opacity: .42; } }

.gauge-wrap { width: min(20rem, 86vw); aspect-ratio: 1; margin: .2rem auto .6rem; position: relative; }
.gauge { width: 100%; height: 100%; transform: rotate(-90deg); overflow: visible; }
.gauge-track, .gauge-progress { fill: none; stroke-width: 12; }
.gauge-track { stroke: rgba(255,255,255,.055); }
.gauge-progress { stroke: url(#gauge-gradient); stroke-linecap: round; transition: stroke-dashoffset .8s cubic-bezier(.2,.8,.2,1); filter: drop-shadow(0 0 8px rgba(85,201,243,.28)); }
.gauge-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.gauge-center span { color: var(--muted); font-size: .84rem; }
.gauge-center strong { margin: .35rem 0; font-size: clamp(2rem, 6vw, 3rem); letter-spacing: -.06em; }
.gauge-center small { color: var(--dim); }

.daily-card { max-width: 32rem; margin: 0 auto 1.4rem; padding: 1rem 1.1rem; background: rgba(255,255,255,.035); border: 1px solid var(--line); border-radius: 1rem; }
.daily-copy { display: flex; align-items: flex-end; justify-content: space-between; gap: .8rem; margin-bottom: .8rem; }
.daily-copy div { display: grid; gap: .2rem; }
.daily-copy span { color: var(--muted); font-size: .72rem; }
.daily-copy strong { font-size: .94rem; }
.progress-track { height: .42rem; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.07); }
.progress-fill { height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--mint), var(--blue)); transition: width .7s ease; }
.timer-actions { max-width: 32rem; margin: auto; }
.button-start, .button-stop { width: 100%; min-height: 4.4rem; display: flex; justify-content: center; align-items: center; gap: 1rem; text-align: left; }
.button-start { color: #0c1a17; background: linear-gradient(135deg, #87f5cd, #5de1d5); box-shadow: 0 10px 30px rgba(89,225,209,.15); }
.button-stop { color: #fff4f6; background: linear-gradient(135deg, #e75e7d, #c44972); box-shadow: 0 10px 30px rgba(231,94,125,.14); }
.action-icon { width: 2.15rem; height: 2.15rem; display: grid; place-items: center; border-radius: 50%; background: rgba(0,0,0,.12); font-size: .78rem; }
.stop-icon { border-radius: .65rem; }
.button-start span:last-child, .button-stop span:last-child { display: grid; gap: .15rem; }
.button-start b, .button-stop b { font-size: 1rem; }
.button-start small, .button-stop small { opacity: .67; font-size: .7rem; }
.limit-note { margin: .9rem 0 0; text-align: center; color: var(--dim); font-size: .7rem; }

.side-column { display: grid; gap: 1.2rem; align-content: start; }
.section-heading { margin-bottom: 1rem; }
.section-heading h2, .modal-heading h2 { margin-bottom: 0; font-size: 1.15rem; }
.section-heading.compact { align-items: center; }
.tiny-label { padding: .35rem .55rem; border: 1px solid var(--line); border-radius: 999px; color: var(--dim); font-size: .62rem; }
.section-copy, .rules-card > p { color: var(--muted); font-size: .78rem; line-height: 1.7; }
.adjustment-buttons { display: grid; gap: .75rem; }
.adjustment { width: 100%; display: flex; align-items: center; gap: .85rem; padding: .9rem; text-align: left; border-radius: 1rem; border: 1px solid var(--line); cursor: pointer; transition: transform .18s, border-color .18s; }
.adjustment:hover { transform: translateY(-2px); }
.adjustment.positive { color: #d9fff0; background: rgba(118,237,193,.07); }
.adjustment.positive:hover { border-color: rgba(118,237,193,.3); }
.adjustment.negative { color: #ffe2e8; background: rgba(255,111,136,.065); }
.adjustment.negative:hover { border-color: rgba(255,111,136,.28); }
.adjustment-icon { width: 2.3rem; height: 2.3rem; display: grid; place-items: center; border-radius: .75rem; font-size: 1.2rem; background: rgba(255,255,255,.06); }
.adjustment > span:last-child { display: grid; gap: .2rem; }
.adjustment b { font-size: .86rem; }
.adjustment small { color: var(--muted); font-size: .68rem; }
.rule-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-bottom: 1rem; }
.rule-grid div { display: grid; padding: .85rem; border-radius: .85rem; background: rgba(255,255,255,.035); }
.rule-grid strong { color: var(--blue); font-size: 1.65rem; }
.rule-grid strong small { margin-left: .2rem; font-size: .65rem; color: var(--muted); }
.rule-grid span { color: var(--dim); font-size: .64rem; }
.rules-card > p { margin-bottom: 0; }

.history-card { grid-column: 1 / -1; }
.icon-button { width: 2rem; height: 2rem; display: grid; place-items: center; border-radius: .65rem; color: var(--muted); background: rgba(255,255,255,.04); font-size: 1.15rem; }
.icon-button:hover { color: var(--text); background: rgba(255,255,255,.08); }
.history-list { display: grid; }
.history-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .9rem; padding: .85rem 0; border-top: 1px solid var(--line); }
.history-row:first-child { border-top: 0; }
.history-icon { width: 2.15rem; height: 2.15rem; display: grid; place-items: center; border-radius: .7rem; font-weight: 900; background: rgba(85,201,243,.09); color: var(--blue); }
.history-icon.positive { color: var(--mint); background: rgba(118,237,193,.09); }
.history-icon.negative { color: var(--coral); background: rgba(255,130,157,.09); }
.history-row > div { display: grid; min-width: 0; gap: .2rem; }
.history-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .82rem; }
.history-row span, .history-row time { color: var(--dim); font-size: .68rem; }
.empty-state { padding: 1.5rem 0 .4rem; color: var(--dim); text-align: center; font-size: .78rem; }

.modal { width: min(28rem, calc(100% - 2rem)); color: var(--text); background: var(--panel-solid); border: 1px solid var(--line); border-radius: 1.3rem; box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(3,4,9,.75); backdrop-filter: blur(6px); }
.modal form { padding: .6rem; }
.modal-heading { margin-bottom: .4rem; }
.password-hint { margin: -.2rem 0 0; color: var(--dim); font-size: .7rem; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.toast { position: fixed; z-index: 30; left: 50%; bottom: 1.5rem; transform: translate(-50%, 1rem); padding: .75rem 1rem; color: #09231b; background: var(--mint); border-radius: .8rem; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; font-size: .78rem; font-weight: 800; }
.toast.error { color: white; background: var(--danger); }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 780px) {
  .topbar { min-height: 4rem; padding-inline: 1rem; }
  .account-area { gap: .45rem; }
  .account-area #display-name, .online-dot { display: none; }
  .dashboard-shell { width: min(100% - 1.2rem, 38rem); grid-template-columns: 1fr; padding-top: .65rem; }
  .hero-panel { grid-row: auto; padding: 1.25rem; }
  .side-column { grid-row: auto; }
  .history-card { grid-column: auto; }
  .history-row { grid-template-columns: auto minmax(0,1fr); }
  .history-row time { grid-column: 2; }
  .gauge-wrap { width: min(17rem, 76vw); }
  .login-card { padding: 2rem 1.3rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
