:root {
  --bg: var(--tg-theme-bg-color, #f3efe6);
  --surface: var(--tg-theme-secondary-bg-color, rgba(255, 255, 255, 0.8));
  --surface-strong: var(--tg-theme-section-bg-color, rgba(255, 255, 255, 0.92));
  --text: var(--tg-theme-text-color, #181716);
  --muted: var(--tg-theme-hint-color, #6d665f);
  --accent: var(--tg-theme-button-color, #174f40);
  --accent-text: var(--tg-theme-button-text-color, #f8f4ea);
  --line: var(--tg-theme-section-separator-color, rgba(24, 23, 22, 0.12));
  --danger: var(--tg-theme-destructive-text-color, #c04937);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --shadow: 0 18px 42px rgba(19, 24, 22, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(226, 206, 165, 0.55), transparent 32%),
    radial-gradient(circle at top right, rgba(23, 79, 64, 0.18), transparent 28%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0.18)),
    var(--bg);
  color: var(--text);
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
}

body {
  min-height: 100vh;
}

.app-shell {
  min-height: 100vh;
  padding:
    calc(var(--safe-top) + 1rem)
    calc(var(--safe-right) + 1rem)
    calc(var(--safe-bottom) + 5.5rem)
    calc(var(--safe-left) + 1rem);
}

.hero {
  margin-bottom: 1rem;
}

.hero__eyebrow {
  display: inline-block;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.72rem;
  background: rgba(23, 79, 64, 0.08);
  color: var(--muted);
}

.hero__title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.85rem;
}

.hero h1 {
  margin: 0;
  font-family: "Baskerville", "Times New Roman", serif;
  font-size: clamp(2.3rem, 9vw, 3.6rem);
  line-height: 0.92;
  letter-spacing: -0.05em;
}

.hero__lede {
  margin: 0.75rem 0 0;
  max-width: 42rem;
  font-size: 1rem;
  line-height: 1.45;
  color: var(--muted);
}

.pill {
  border-radius: 999px;
  padding: 0.45rem 0.75rem;
  font-size: 0.82rem;
  border: 1px solid var(--line);
}

.pill--ghost {
  background: rgba(255, 255, 255, 0.54);
  backdrop-filter: blur(18px);
}

.tabbar {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.45rem;
  position: sticky;
  top: calc(var(--safe-top) + 0.5rem);
  z-index: 10;
  padding: 0.4rem;
  margin-bottom: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 1rem;
  background: rgba(247, 242, 232, 0.78);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.tabbar__button {
  min-height: 48px;
  border: 0;
  border-radius: 0.85rem;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 600;
}

.tabbar__button.is-active {
  background: var(--accent);
  color: var(--accent-text);
}

.screen {
  display: grid;
  gap: 1rem;
}

.panel {
  padding: 1rem;
  border-radius: 1.15rem;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: var(--surface);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.panel h2,
.panel h3 {
  margin: 0 0 0.65rem;
  font-family: "Baskerville", "Times New Roman", serif;
  font-weight: 600;
}

.panel h2 {
  font-size: 1.45rem;
}

.panel h3 {
  font-size: 1.1rem;
}

.grid {
  display: grid;
  gap: 1rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.stat {
  padding: 0.85rem;
  border-radius: 0.95rem;
  background: var(--surface-strong);
  border: 1px solid var(--line);
}

.stat__label {
  margin: 0;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.stat__value {
  margin: 0.35rem 0 0;
  font-size: 1.7rem;
  line-height: 1;
}

.list {
  display: grid;
  gap: 0.8rem;
}

.item {
  padding: 0.9rem;
  border-radius: 0.95rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.36);
}

.item__meta {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.item__title {
  margin: 0;
  font-size: 1rem;
  line-height: 1.35;
}

.item__summary {
  margin: 0.5rem 0 0;
  white-space: pre-wrap;
  color: var(--muted);
  line-height: 1.45;
}

.capture-form {
  display: grid;
  gap: 0.8rem;
}

.capture-form textarea,
.capture-form select {
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.6);
  color: var(--text);
  font: inherit;
  padding: 0.85rem 1rem;
}

.capture-form textarea {
  min-height: 160px;
  resize: vertical;
  line-height: 1.45;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.button {
  min-height: 46px;
  padding: 0.7rem 1rem;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-weight: 600;
}

.button--ghost {
  background: rgba(255, 255, 255, 0.5);
  color: var(--text);
  border: 1px solid var(--line);
}

.button--danger {
  background: var(--danger);
}

.empty {
  color: var(--muted);
  font-style: italic;
}

.mono {
  font-family: "SFMono-Regular", "Menlo", "Consolas", monospace;
  font-size: 0.9rem;
}

.loading-grid {
  display: grid;
  gap: 0.85rem;
}

.loading-line {
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(23, 79, 64, 0.08), rgba(23, 79, 64, 0.18), rgba(23, 79, 64, 0.08));
  background-size: 220% 100%;
  animation: shimmer 1.2s linear infinite;
}

.loading-line--wide {
  width: 92%;
}

.loading-line--short {
  width: 48%;
}

.flash {
  padding: 0.8rem 0.95rem;
  border-radius: 0.95rem;
  border: 1px solid var(--line);
  background: rgba(23, 79, 64, 0.08);
}

.flash--error {
  background: rgba(192, 73, 55, 0.12);
  color: var(--danger);
}

@keyframes shimmer {
  0% {
    background-position: 0% 0%;
  }
  100% {
    background-position: 200% 0%;
  }
}

@media (min-width: 700px) {
  .app-shell {
    padding-left: max(calc(var(--safe-left) + 1.25rem), 6vw);
    padding-right: max(calc(var(--safe-right) + 1.25rem), 6vw);
  }

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