:root {
  --bg: #09090b;
  --surface: #121216;
  --surface-2: #19191f;
  --border: #2b2b32;
  --gold: #e5bb62;
  --gold-light: #ffe2a0;
  --text: #f6f4ef;
  --muted: #a5a3aa;
  --danger: #ff7777;
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  color-scheme: dark;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at top, #201a0f 0, transparent 38%),
    var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

.app {
  width: 100%;
  max-width: 560px;
  min-height: 100vh;
  margin: 0 auto;
  padding-bottom: 112px;
  background: rgba(9, 9, 11, 0.93);
  border-left: 1px solid #17171b;
  border-right: 1px solid #17171b;
}

.topbar {
  min-height: 104px;
  padding: 24px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.topbar h1 {
  margin: 2px 0 0;
  font-size: clamp(19px, 5vw, 24px);
  letter-spacing: 1.1px;
  font-weight: 900;
}

.topbar h1 span {
  color: var(--gold);
}

.eyebrow {
  margin: 0;
  color: var(--gold);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 2px;
}

.live-indicator {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 18px #e5bb6266;
  flex-shrink: 0;
}

main {
  padding: 22px 16px 32px;
}

.page {
  display: none;
  animation: page-in 0.2s ease-out;
}

.page.active {
  display: block;
}

@keyframes page-in {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.page-heading {
  margin: 4px 0 22px;
}

.page-heading h2 {
  margin: 5px 0;
  font-size: 31px;
  line-height: 1.2;
  letter-spacing: -0.8px;
}

.muted,
.field-hint {
  color: var(--muted);
}

.muted {
  margin: 5px 0 0;
  font-size: 13px;
}

.field-hint {
  margin: 8px 0 14px;
  font-size: 12px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stat-card,
.summary-card {
  min-width: 0;
  padding: 18px 15px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: linear-gradient(145deg, #1a1a1f, #101013);
}

.stat-card span,
.summary-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.stat-card strong,
.summary-card strong {
  display: block;
  margin-top: 8px;
  font-size: 27px;
  line-height: 1.2;
  overflow-wrap: anywhere;
  color: var(--gold-light);
}

.panel {
  padding: 19px;
  margin-bottom: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.panel-heading h3,
.section-title h3 {
  margin: 3px 0 0;
  font-size: 19px;
}

.gold-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: #332918;
  color: var(--gold);
  font-size: 25px;
}

label {
  display: block;
  margin: 15px 0 7px;
  color: #e9e7e1;
  font-size: 13px;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 13px;
  border: 1px solid #34343c;
  border-radius: 12px;
  background: #0c0c0f;
  color: var(--text);
}

input::placeholder,
textarea::placeholder {
  color: #777680;
}

input[type="date"],
input[type="month"] {
  min-width: 0;
}

textarea {
  min-height: 88px;
  resize: vertical;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.button-row {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.primary-button,
.secondary-button {
  min-height: 49px;
  padding: 12px 16px;
  border-radius: 12px;
  font-weight: 800;
}

.primary-button {
  width: 100%;
  border: 1px solid var(--gold);
  background: linear-gradient(135deg, var(--gold-light), #c99b3d);
  color: #18130a;
}

.primary-button:active {
  transform: scale(0.99);
}

.secondary-button {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}

.hidden {
  display: none !important;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 26px 0 13px;
}

.count-badge {
  display: inline-grid;
  place-items: center;
  min-width: 32px;
  min-height: 32px;
  padding: 0 9px;
  border: 1px solid #59472a;
  border-radius: 10px;
  color: var(--gold);
  font-size: 13px;
  font-weight: 800;
}

.entry-list,
.history-list {
  display: grid;
  gap: 12px;
}

.entry-card,
.history-day {
  min-width: 0;
  padding: 17px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: linear-gradient(145deg, #17171c, #101013);
}

.entry-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.entry-top h4 {
  margin: 0;
  font-size: 17px;
  overflow-wrap: anywhere;
}

.entry-date {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.gold-tag {
  flex-shrink: 0;
  padding: 5px 8px;
  border-radius: 8px;
  background: #322817;
  color: var(--gold-light);
  font-size: 11px;
  font-weight: 800;
}

.entry-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 15px 0;
}

.metric {
  padding: 11px;
  border-radius: 10px;
  background: #0b0b0e;
  border: 1px solid #24242a;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.metric strong {
  display: block;
  margin-top: 3px;
  font-size: 15px;
  overflow-wrap: anywhere;
}

.entry-notes {
  margin: 10px 0;
  color: #c6c3ca;
  font-size: 13px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.entry-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.small-button {
  padding: 8px 11px;
  border: 1px solid #36363e;
  border-radius: 9px;
  background: #202026;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.small-button.delete {
  color: var(--danger);
}

.steps-hero {
  padding: 24px 20px;
  margin-bottom: 18px;
  border: 1px solid #5a4625;
  border-radius: 20px;
  background:
    radial-gradient(ellipse at top right, #4b371b66, transparent 65%),
    #17140e;
}

.steps-hero > strong {
  display: block;
  margin-top: 12px;
  font-size: clamp(37px, 10vw, 54px);
  line-height: 1.1;
  letter-spacing: -1.5px;
  color: var(--gold-light);
  overflow-wrap: anywhere;
}

.steps-hero > span {
  color: var(--muted);
  font-size: 13px;
}

.progress-track {
  width: 100%;
  height: 9px;
  margin-top: 20px;
  overflow: hidden;
  border-radius: 20px;
  background: #3b3427;
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #bb8730, var(--gold-light));
  transition: width 0.25s ease;
}

.period-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  padding: 5px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #111114;
}

.period-button {
  min-width: 0;
  min-height: 42px;
  padding: 8px 4px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.period-button.active {
  background: linear-gradient(135deg, var(--gold-light), #c99b3d);
  color: #19130a;
}

.filter-panel {
  padding: 15px;
}

.history-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 17px 0;
}

.summary-card {
  padding: 15px 13px;
}

.summary-card strong {
  font-size: 23px;
}

.history-extra {
  display: grid;
  gap: 0;
  padding: 5px 16px;
}

.history-extra > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}

.history-extra > div:last-child {
  border-bottom: 0;
}

.history-extra span {
  color: var(--muted);
  font-size: 12px;
}

.history-extra strong {
  color: var(--gold-light);
  text-align: right;
  font-size: 14px;
}

.history-day-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  padding-bottom: 13px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.history-day-heading h4 {
  margin: 0;
  font-size: 16px;
}

.history-day-heading p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.history-subsection {
  margin: 14px 0 8px;
  color: var(--gold);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.history-item {
  padding: 12px 0;
  border-bottom: 1px solid #25252b;
}

.history-item:last-child {
  border-bottom: 0;
}

.history-item h5 {
  margin: 0 0 6px;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.history-item p {
  margin: 4px 0;
  color: #c2c0c7;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.history-item .history-note {
  color: var(--muted);
  white-space: pre-wrap;
}

.empty-state {
  padding: 26px 17px;
  border: 1px dashed #373740;
  border-radius: 15px;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.storage-note {
  margin: 24px 3px 8px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.bottom-nav {
  position: fixed;
  z-index: 10;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: min(100%, 560px);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid #35312a;
  background: rgba(12, 12, 15, 0.97);
  backdrop-filter: blur(18px);
}

.nav-button {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 58px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.nav-icon {
  font-size: 10px;
  letter-spacing: 1px;
  font-weight: 900;
}

.nav-button.active {
  background: #2a2215;
  color: var(--gold-light);
}

@media (min-width: 700px) {
  body {
    padding: 24px 0;
  }

  .app {
    min-height: calc(100vh - 48px);
    border: 1px solid var(--border);
    border-radius: 24px;
    overflow: hidden;
  }

  .bottom-nav {
    bottom: 24px;
    border: 1px solid #35312a;
    border-radius: 0 0 24px 24px;
  }
}

@media (max-width: 380px) {
  main {
    padding-right: 12px;
    padding-left: 12px;
  }

  .panel {
    padding: 15px;
  }

  .page-heading h2 {
    font-size: 27px;
  }

  .summary-card strong {
    font-size: 20px;
  }
}