:root {
  color-scheme: light;
  --bg: #eef5ff;
  --surface: #ffffff;
  --surface-strong: #e7eefb;
  --text: #111827;
  --muted: #64748b;
  --line: #d7e2f2;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --accent: #06b6d4;
  --danger: #b83d35;
  --shadow: 0 14px 34px rgba(37, 99, 235, 0.11);
  font-family: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

:root[data-theme="aurora"] {
  --bg: #ecfdf8;
  --surface: #ffffff;
  --surface-strong: #dff7ee;
  --text: #10201c;
  --muted: #5f716c;
  --line: #cbe7dc;
  --primary: #0f8a74;
  --primary-dark: #096554;
  --accent: #14b8a6;
  --shadow: 0 14px 34px rgba(15, 138, 116, 0.11);
}

:root[data-theme="violet"] {
  --bg: #f5f3ff;
  --surface: #ffffff;
  --surface-strong: #ebe7ff;
  --text: #17132b;
  --muted: #6f6a86;
  --line: #ded8ff;
  --primary: #6d5dfc;
  --primary-dark: #5548d9;
  --accent: #ec4899;
  --shadow: 0 14px 34px rgba(109, 93, 252, 0.12);
}

:root[data-theme="ember"] {
  --bg: #fff7ed;
  --surface: #ffffff;
  --surface-strong: #ffead5;
  --text: #251912;
  --muted: #7c6657;
  --line: #f3d4b6;
  --primary: #e85d2a;
  --primary-dark: #c4491d;
  --accent: #f59e0b;
  --shadow: 0 14px 34px rgba(232, 93, 42, 0.12);
}

:root[data-theme="midnight"] {
  color-scheme: dark;
  --bg: #08111f;
  --surface: #101b2d;
  --surface-strong: #172640;
  --text: #e8f0ff;
  --muted: #94a3b8;
  --line: #263955;
  --primary: #38bdf8;
  --primary-dark: #0ea5e9;
  --accent: #a78bfa;
  --danger: #fb7185;
  --shadow: 0 16px 42px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 18% 0%, color-mix(in srgb, var(--primary) 15%, transparent), transparent 28rem),
    linear-gradient(180deg, var(--bg), color-mix(in srgb, var(--bg) 86%, var(--surface)));
  color: var(--text);
}

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

button {
  cursor: pointer;
}

.app-shell {
  width: min(100%, 860px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px calc(84px + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
}

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

h1 {
  margin-bottom: 0;
  font-size: 1.9rem;
  line-height: 1.15;
}

h2 {
  margin-bottom: 12px;
  font-size: 1.08rem;
}

h3 {
  margin-bottom: 10px;
  font-size: 1rem;
}

.hero-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.hero-strip > div {
  min-width: 0;
  padding: 13px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-label,
label > span,
.hint,
.credit,
.entry-meta,
.entry-date,
.empty {
  color: var(--muted);
  font-size: 0.84rem;
}

.credit {
  margin: 18px 0 0;
  text-align: center;
}

.hero-strip strong {
  display: block;
  margin-top: 5px;
  font-size: 1.05rem;
  line-height: 1.2;
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 8px 0;
  margin-bottom: 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(16px);
}

.tab {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 700;
}

.tab.is-active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

.view {
  display: none;
}

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

.panel,
.entry-card,
.report-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel {
  padding: 16px;
  margin-bottom: 14px;
}

.stack {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 10px 11px;
}

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

input[type="range"] {
  padding: 0;
}

.two-grid,
.filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.toolbar {
  margin-bottom: 12px;
}

.primary,
.secondary,
.file-button {
  min-height: 46px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 14px;
  font-weight: 800;
}

.primary {
  background: var(--primary);
  color: #fff;
}

.secondary,
.file-button {
  background: var(--surface-strong);
  color: var(--text);
  text-align: center;
}

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

.theme-option {
  display: grid;
  min-height: 64px;
  place-items: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  padding: 8px;
  font-size: 0.8rem;
  font-weight: 800;
}

.theme-option.is-active {
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: inset 0 0 0 1px var(--primary);
}

.theme-swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--swatch) 18%, transparent);
}

.icon-button {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 1.6rem;
  line-height: 1;
}

.text-button {
  min-height: 36px;
  border: 0;
  background: transparent;
  color: var(--primary);
  font-weight: 800;
  padding: 6px 2px;
}

.danger {
  color: var(--danger);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0 10px;
}

.section-head h2 {
  margin: 0;
}

.entry-list,
.report-list {
  display: grid;
  gap: 10px;
}

.entry-card {
  padding: 14px;
}

.entry-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.entry-content {
  margin-bottom: 10px;
  white-space: pre-wrap;
  line-height: 1.55;
}

.entry-image {
  width: 100%;
  max-height: 360px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  margin-bottom: 10px;
}

.entry-actions {
  display: flex;
  gap: 18px;
}

.report-card {
  padding: 16px;
}

.report-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.report-metrics div {
  min-width: 0;
  padding: 10px;
  border-radius: 8px;
  background: var(--surface-strong);
}

.bar-list {
  display: grid;
  gap: 8px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(72px, 0.9fr) minmax(80px, 2fr) auto;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.86rem;
}

.bar-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-strong);
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.chip-list,
.data-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  padding: 6px 10px;
  color: var(--muted);
  font-size: 0.88rem;
}

.chip button {
  border: 0;
  background: transparent;
  color: var(--danger);
  font-weight: 900;
  padding: 0;
}

.file-button input {
  display: none;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 10;
  max-width: min(360px, calc(100vw - 32px));
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--text);
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
}

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

@media (min-width: 720px) {
  .view#view-today.is-active {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    align-items: start;
  }

  .view#view-today .toolbar,
  .view#view-today .section-head,
  .view#view-today #todayEntries {
    grid-column: 1 / -1;
  }
}

@media (max-width: 520px) {
  .app-shell {
    padding-inline: 12px;
  }

  h1 {
    font-size: 1.55rem;
  }

  .hero-strip {
    grid-template-columns: 1fr;
  }

  .filters,
  .two-grid,
  .report-metrics,
  .theme-grid {
    grid-template-columns: 1fr 1fr;
  }

  .bar-row {
    grid-template-columns: 1fr;
  }

  .tabs {
    bottom: 0;
    top: auto;
    position: fixed;
    left: 0;
    right: 0;
    width: min(100%, 860px);
    margin: 0 auto;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
  }
}
