:root {
  --bg: #0A0705;
  --surface: #15100C;
  --border: #2A1F16;
  --text: #F0E4D8;
  --text-muted: #8A7A6C;
  --ember: #E8792E;
  --ember-dim: #7A3E18;
  --ember-glow: rgba(232, 121, 46, 0.35);
  --radius: 14px;
  --pad: 18px;
  --pad-lg: 28px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

.text-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.text-muted { color: var(--text-muted); font-size: 14px; }

/* ===== Buttons ===== */
.btn {
  height: 48px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 500;
  font-family: inherit;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s ease, box-shadow 0.2s ease;
}
.btn-block { width: 100%; }
.btn-primary {
  background: var(--ember);
  color: #150900;
  box-shadow: 0 0 0 rgba(0,0,0,0);
}
.btn-primary:active { opacity: 0.85; }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 0.5px solid var(--border);
}
.link-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  padding: 4px 0;
}
.link-btn:hover { color: var(--ember); }

/* ===== Inputs ===== */
.input {
  width: 100%;
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  padding: 0 14px;
  height: 48px;
}
.input:focus {
  outline: none;
  border-color: var(--ember-dim);
}
.input-big {
  font-family: 'Fraunces', serif;
  font-size: 32px;
  font-weight: 500;
  text-align: center;
  height: 72px;
}

/* ===== Auth screen ===== */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--pad);
}
.auth-card {
  width: 100%;
  max-width: 360px;
  text-align: center;
}
.brand {
  font-family: 'Fraunces', serif;
  font-size: 40px;
  font-weight: 500;
  margin: 0 0 4px;
  background: radial-gradient(ellipse at center, var(--ember) 0%, var(--text) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.auth-sub { color: var(--text-muted); margin: 0 0 28px; font-size: 15px; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-msg { margin-top: 16px; font-size: 13px; color: var(--ember); min-height: 18px; }

.profile-grid { display: flex; flex-direction: column; gap: 12px; }
.profile-btn {
  height: 56px;
  border-radius: 12px;
  border: 0.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: 'Fraunces', serif;
  font-size: 20px;
  font-weight: 500;
  cursor: pointer;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.profile-btn:hover {
  border-color: var(--ember-dim);
  box-shadow: 0 0 30px var(--ember-glow);
}

/* ===== Shell ===== */
.shell {
  display: none;
  min-height: 100vh;
  flex-direction: column;
}
.shell.shown { display: flex; }
.shell-main {
  flex: 1;
  overflow-y: auto;
  padding: var(--pad-lg) var(--pad) 100px;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

/* ===== Log panel ===== */
.ember-focus {
  text-align: center;
  margin: 12px 0 32px;
  position: relative;
}
.glow-title {
  font-family: 'Fraunces', serif;
  font-size: 28px;
  font-weight: 500;
  margin: 0;
  color: var(--text);
  text-shadow: 0 0 40px var(--ember-glow);
}
.log-form { display: flex; flex-direction: column; gap: 20px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-size: 13px; color: var(--text-muted); }

.pull-toggle {
  display: flex;
  border: 0.5px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.seg-btn {
  flex: 1;
  height: 40px;
  background: var(--surface);
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.seg-btn.active {
  background: var(--ember-dim);
  color: var(--text);
}

.log-confirm {
  text-align: center;
  color: var(--ember);
  font-size: 14px;
  min-height: 20px;
  margin-top: 16px;
  transition: opacity 0.4s ease;
}

/* ===== Stats panel ===== */
.streak-block {
  text-align: center;
  margin-bottom: 28px;
}
.streak-num {
  font-family: 'Fraunces', serif;
  font-size: 56px;
  font-weight: 500;
  color: var(--ember);
  text-shadow: 0 0 50px var(--ember-glow);
  line-height: 1;
}
.avg-row {
  display: flex;
  gap: 12px;
  margin-bottom: 28px;
}
.avg-card {
  flex: 1;
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: var(--pad);
}
.avg-num {
  font-family: 'Fraunces', serif;
  font-size: 26px;
  margin-top: 4px;
}
.chart-block {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: var(--pad);
  margin-bottom: 16px;
}
.insight-block {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: var(--pad);
  margin-bottom: 16px;
}
.insight-text { font-size: 15px; line-height: 1.5; margin: 8px 0 12px; }

.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
}
.history-row .skip { color: var(--text-muted); }

.edit-row {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
}
.edit-row-summary {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  cursor: pointer;
}
.edit-row-summary .skip { color: var(--text-muted); }
.edit-row-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 0.5px solid var(--border);
}
.edit-row-form .input { height: 40px; font-size: 14px; }
.edit-row-actions { display: flex; gap: 8px; }
.edit-row-actions .btn { flex: 1; height: 38px; font-size: 14px; }
.btn-danger { background: transparent; color: #C1502E; border: 0.5px solid #4A2418; }

/* ===== Bottom nav ===== */
.bnav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  border-top: 0.5px solid var(--border);
  background: var(--bg);
}
.bnav-item {
  flex: 1;
  height: 56px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.bnav-item.active { color: var(--ember); }

/* ===== Modal ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--pad);
  z-index: 10;
}
.modal-card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: var(--pad-lg);
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; }

@media (min-width: 480px) {
  .shell-main { padding-top: 48px; }
}
