:root {
  --bg: #f6efe7;
  --surface: rgba(255, 252, 247, 0.78);
  --surface-strong: #fffaf4;
  --line: rgba(111, 78, 55, 0.12);
  --text: #2d2119;
  --muted: #7f6958;
  --accent: #ba5d2f;
  --accent-dark: #8b3b16;
  --accent-soft: #f1c9b7;
  --teal: #2e7f7b;
  --shadow: 0 20px 50px rgba(92, 57, 34, 0.12);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Noto Sans HK", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 221, 199, 0.9), transparent 28%),
    radial-gradient(circle at bottom right, rgba(136, 201, 193, 0.32), transparent 26%),
    linear-gradient(135deg, #f8efe5 0%, #f3e3d4 44%, #f8f4ef 100%);
}

button,
input,
select {
  font: inherit;
}

.page-shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

.hero {
  display: block;
  margin-bottom: 24px;
}

.hero-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.lang-toggle {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(111, 78, 55, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  line-height: 1;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.lang-toggle:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(111, 78, 55, 0.2);
}

.hero h1,
.panel h2 {
  margin: 0;
  line-height: 1;
}

.hero h1 {
  font-family: "DM Serif Display", serif;
  font-size: clamp(3.2rem, 7vw, 5.8rem);
  margin-bottom: 16px;
}

.eyebrow,
.section-kicker {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--muted);
  font-size: 0.78rem;
  margin: 0 0 12px;
}

.hero-copy,
.form-hint {
  color: var(--muted);
  max-width: 54ch;
  line-height: 1.6;
}

.panel {
  backdrop-filter: blur(14px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.stat-card span {
  display: block;
  color: var(--muted);
  margin-bottom: 8px;
}

.stat-card strong {
  font-size: 1.9rem;
}

.layout,
.dashboard,
.grid {
  display: grid;
  gap: 24px;
}

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

.auth-panel,
.topbar,
.entry-panel,
.stats-panel,
.chart-panel,
.history-panel {
  padding: 24px;
}

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

.entry-panel {
  grid-column: span 5;
}

.stats-panel {
  grid-column: span 7;
}

.chart-panel {
  grid-column: span 6;
}

.history-panel {
  grid-column: span 12;
}

.stack-form,
.history-list {
  display: grid;
  gap: 16px;
}

.smart-timing,
.smart-timing-copy {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.smart-timing {
  padding: 16px 18px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(111, 78, 55, 0.08);
  background: linear-gradient(180deg, rgba(255,255,255,0.72), rgba(252,240,233,0.92));
}

.smart-timing-copy {
  align-items: flex-start;
  flex-direction: column;
}

.smart-timing-copy span {
  color: var(--muted);
  font-size: 0.9rem;
}

.smart-timing-copy strong {
  font-size: 1rem;
  line-height: 1.4;
}

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

label span {
  font-weight: 600;
}

input,
select {
  width: 100%;
  border: 1px solid rgba(111, 78, 55, 0.14);
  background: rgba(255, 255, 255, 0.72);
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  color: var(--text);
}

input:focus,
select:focus {
  outline: 2px solid rgba(46, 127, 123, 0.24);
  border-color: rgba(46, 127, 123, 0.38);
}

.two-col,
.three-col,
.stat-cards {
  display: grid;
  gap: 14px;
}

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

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

.stat-cards {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 20px;
}

.stat-card {
  padding: 20px;
  background: linear-gradient(180deg, rgba(255,255,255,0.72), rgba(252,240,233,0.9));
  border-radius: var(--radius-md);
  border: 1px solid rgba(111, 78, 55, 0.09);
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  cursor: pointer;
  transition: transform 160ms ease, opacity 160ms ease, background 160ms ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
}

.btn-secondary,
.btn-ghost {
  background: rgba(255, 255, 255, 0.75);
  color: var(--text);
  border: 1px solid rgba(111, 78, 55, 0.1);
}

.session-tag {
  border-radius: 999px;
  padding: 8px 14px;
  background: rgba(46, 127, 123, 0.12);
  color: var(--teal);
  font-weight: 700;
}

.history-item {
  display: grid;
  grid-template-columns: 1.2fr 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 18px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid rgba(111, 78, 55, 0.08);
}

.history-meta strong {
  display: block;
  margin-bottom: 4px;
}

.history-values {
  display: flex;
  gap: 18px;
  color: var(--muted);
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(186, 93, 47, 0.1);
  color: var(--accent-dark);
  font-size: 0.85rem;
  font-weight: 700;
}

.empty-state {
  padding: 32px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed rgba(111, 78, 55, 0.2);
  border-radius: var(--radius-md);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  padding: 14px 18px;
  background: rgba(45, 33, 25, 0.92);
  color: #fff;
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.hidden {
  display: none !important;
}

canvas {
  width: 100% !important;
  height: 320px !important;
  margin-top: 10px;
}

@media (max-width: 960px) {
  .hero,
  .grid {
    grid-template-columns: 1fr;
  }

  .entry-panel,
  .stats-panel,
  .chart-panel,
  .history-panel {
    grid-column: span 1;
  }
}

@media (max-width: 640px) {
  .page-shell {
    padding: 18px 14px 40px;
  }

  .hero-topbar,
  .topbar,
  .panel-heading,
  .topbar-actions,
  .auth-actions,
  .smart-timing,
  .smart-timing-copy,
  .history-item,
  .two-col,
  .three-col,
  .stat-cards {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .hero h1 {
    font-size: 3.2rem;
  }

  .history-item {
    display: grid;
  }
}
