:root {
  --bg: #071018;
  --bg-2: #0b1722;
  --surface: rgba(15, 28, 42, 0.88);
  --surface-strong: rgba(20, 38, 56, 0.96);
  --surface-soft: rgba(16, 32, 48, 0.68);
  --ink: #ecf7ff;
  --muted: #91a7b8;
  --subtle: #5f7688;
  --line: rgba(120, 211, 255, 0.18);
  --line-strong: rgba(120, 211, 255, 0.34);
  --cyan: #4dd8ff;
  --green: #4df0a6;
  --green-dark: #20b977;
  --blue: #5d8cff;
  --violet: #a78bfa;
  --yellow: #f2c94c;
  --coral: #ff7a5c;
  --danger: #ff4f6d;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.34);
  color-scheme: dark;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(77, 216, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(77, 216, 255, 0.035) 1px, transparent 1px),
    radial-gradient(circle at 18% 4%, rgba(77, 216, 255, 0.18), transparent 26rem),
    radial-gradient(circle at 92% 12%, rgba(77, 240, 166, 0.14), transparent 28rem),
    linear-gradient(145deg, #071018 0%, #0c1824 48%, #08121b 100%);
  background-size: 34px 34px, 34px 34px, auto, auto, auto;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
label.import-button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

button:hover,
label.import-button:hover {
  transform: translateY(-1px);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
label.import-button:focus-visible {
  outline: 3px solid rgba(77, 216, 255, 0.28);
  outline-offset: 2px;
}

.app-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px;
  border-right: 1px solid var(--line);
  background: rgba(7, 16, 24, 0.82);
  backdrop-filter: blur(18px);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 1px solid rgba(77, 216, 255, 0.45);
  border-radius: 8px;
  color: #061018;
  background: linear-gradient(135deg, var(--cyan), var(--green));
  font-weight: 900;
  box-shadow: 0 0 28px rgba(77, 216, 255, 0.25);
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--cyan);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 1.18rem;
  line-height: 1.2;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.7rem, 3vw, 2.5rem);
  line-height: 1.08;
}

h3 {
  margin-bottom: 0;
  font-size: clamp(1.28rem, 2.3vw, 1.9rem);
  line-height: 1.16;
}

h4 {
  margin-bottom: 0;
  font-size: 1rem;
  line-height: 1.35;
}

.nav-tabs {
  display: grid;
  gap: 8px;
  overflow-y: auto;
  padding-right: 2px;
}

.nav-tab {
  width: 100%;
  padding: 12px 14px;
  text-align: left;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
}

.nav-tab.is-active {
  color: var(--ink);
  background: linear-gradient(90deg, rgba(77, 216, 255, 0.16), rgba(77, 240, 166, 0.06));
  border-color: var(--line-strong);
  box-shadow: inset 4px 0 0 var(--cyan), 0 0 22px rgba(77, 216, 255, 0.08);
}

.storage-panel {
  margin-top: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.storage-panel p {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.storage-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

#importData {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.main {
  min-width: 0;
  padding: 28px;
}

.topbar,
.section-heading,
.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.topbar {
  margin-bottom: 28px;
}

.topbar-stats,
.button-row,
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.topbar-stats span,
.panel-heading span,
.save-state {
  min-height: 32px;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--muted);
  background: rgba(7, 16, 24, 0.58);
  border: 1px solid var(--line);
  font-size: 0.84rem;
  white-space: nowrap;
}

.view {
  display: none;
}

.view.is-visible {
  display: block;
}

.section-heading {
  margin-bottom: 18px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.metric-card,
.panel,
.item-card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(17, 34, 50, 0.92), rgba(12, 25, 38, 0.88));
  box-shadow: var(--shadow);
}

.metric-card::before,
.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(77, 216, 255, 0.12), transparent 28%, transparent 70%, rgba(77, 240, 166, 0.08));
}

.metric-card > *,
.panel > * {
  position: relative;
}

.metric-card {
  min-height: 122px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
}

.metric-card strong {
  display: block;
  color: var(--ink);
  font-size: 2rem;
  line-height: 1;
}

.metric-card span {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.content-grid {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.dashboard-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.wide-left {
  grid-template-columns: minmax(320px, 0.85fr) minmax(0, 1.15fr);
}

.panel {
  padding: 18px;
}

.chart-panel {
  min-height: 300px;
}

.panel-heading {
  margin-bottom: 14px;
}

.compact-heading {
  margin-bottom: 10px;
}

.primary-button,
.secondary-button,
.danger-button,
.ghost-button,
label.import-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 13px;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
}

.primary-button {
  color: #04131b;
  background: linear-gradient(135deg, var(--cyan), var(--green));
  box-shadow: 0 0 24px rgba(77, 216, 255, 0.18);
}

.primary-button:hover {
  box-shadow: 0 0 30px rgba(77, 216, 255, 0.28);
}

.secondary-button,
label.import-button,
.ghost-button {
  color: var(--ink);
  background: rgba(77, 216, 255, 0.08);
  border: 1px solid var(--line);
}

.ghost-button {
  min-height: 34px;
  padding: 7px 10px;
  background: transparent;
}

.danger-button {
  width: 100%;
  color: white;
  background: rgba(255, 79, 109, 0.82);
}

.segmented {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(7, 16, 24, 0.62);
}

.segmented button {
  min-height: 28px;
  padding: 5px 9px;
  color: var(--muted);
  background: transparent;
}

.segmented button.is-active {
  color: #061018;
  background: var(--cyan);
}

.form-panel {
  display: grid;
  gap: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

label,
.full-label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.span-two,
.full-label {
  grid-column: 1 / -1;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  background: rgba(3, 10, 16, 0.74);
}

textarea {
  resize: vertical;
  line-height: 1.55;
}

input[type="range"] {
  padding: 0;
  accent-color: var(--cyan);
}

output {
  color: var(--cyan);
  font-weight: 900;
}

.form-note {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.6;
}

.domain-score-list,
.trend-grid,
.stack-list,
.insight-list,
.habit-check-list,
.review-summary,
.stat-list {
  display: grid;
  gap: 10px;
}

.domain-row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) 44px;
  gap: 10px;
  align-items: center;
}

.progress {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(145, 167, 184, 0.18);
}

.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--green));
}

.item-card {
  padding: 14px;
  box-shadow: none;
  background: rgba(7, 16, 24, 0.64);
}

.item-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.item-title {
  margin-bottom: 4px;
  font-weight: 900;
  line-height: 1.35;
}

.item-meta,
.item-note {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 8px;
  border-radius: 999px;
  color: #061018;
  background: var(--blue);
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.pill.physical {
  background: var(--green);
}

.pill.mental {
  background: var(--violet);
  color: #fff;
}

.pill.work {
  background: var(--blue);
  color: #fff;
}

.pill.learning {
  background: var(--yellow);
}

.pill.life {
  background: var(--coral);
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.inline-actions button {
  min-height: 32px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: transparent;
}

.inline-actions button:hover {
  color: var(--ink);
  border-color: var(--line-strong);
}

.habit-check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(7, 16, 24, 0.64);
  color: var(--ink);
}

.habit-check input {
  width: 20px;
  height: 20px;
  min-height: auto;
  accent-color: var(--cyan);
}

.habit-check span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.domain-checkboxes {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.domain-checkboxes label {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(7, 16, 24, 0.62);
  color: var(--ink);
}

.domain-checkboxes input {
  width: 16px;
  min-height: auto;
  accent-color: var(--cyan);
}

.insight {
  padding: 12px;
  border-left: 4px solid var(--green);
  border-radius: 8px;
  background: rgba(7, 16, 24, 0.64);
  line-height: 1.55;
}

.insight.warning {
  border-color: var(--coral);
}

.insight.neutral {
  border-color: var(--blue);
}

.insight.positive {
  border-color: var(--green);
}

.empty-state {
  padding: 18px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(7, 16, 24, 0.54);
  line-height: 1.6;
}

.review-line,
.stat-row {
  display: grid;
  grid-template-columns: minmax(118px, 0.8fr) minmax(0, 1.2fr);
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.review-line:last-child,
.stat-row:last-child {
  border-bottom: 0;
}

.review-line strong,
.stat-row strong {
  display: block;
  color: var(--ink);
  font-size: 1.25rem;
}

.chart-box {
  min-height: 238px;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.chart-box svg {
  width: 100%;
  height: auto;
  max-height: 280px;
  display: block;
}

.chart-empty {
  width: 100%;
  min-height: 220px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
  padding: 18px;
}

.chart-label {
  fill: var(--muted);
  font-size: 12px;
}

.chart-value {
  fill: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface-strong);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-tabs {
    grid-template-columns: repeat(9, minmax(118px, 1fr));
    grid-auto-flow: column;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 4px;
  }

  .nav-tab {
    text-align: center;
  }

  .storage-panel {
    margin-top: 0;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 840px) {
  .main,
  .sidebar {
    padding: 18px;
  }

  .topbar,
  .section-heading,
  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-stats,
  .button-row {
    justify-content: flex-start;
  }

  .two-col,
  .wide-left,
  .dashboard-grid,
  .form-grid,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .domain-row {
    grid-template-columns: 76px minmax(0, 1fr) 38px;
  }

  .storage-actions,
  .domain-checkboxes {
    grid-template-columns: 1fr;
  }

  .primary-button,
  .secondary-button,
  .danger-button,
  .ghost-button,
  label.import-button {
    width: 100%;
  }

  .inline-actions button,
  .segmented button {
    width: auto;
  }

  .chart-panel {
    min-height: 260px;
  }
}

@media (max-width: 460px) {
  .brand {
    grid-template-columns: 44px minmax(0, 1fr);
  }

  .brand-mark {
    width: 44px;
    height: 44px;
  }

  .panel,
  .metric-card {
    padding: 14px;
  }

  .review-line,
  .stat-row {
    grid-template-columns: 1fr;
  }

  .chart-box {
    min-height: 210px;
  }
}
