:root {
  --bg: #f4efe7;
  --panel: rgba(255, 255, 255, 0.9);
  --panel-strong: #ffffff;
  --line: rgba(18, 53, 36, 0.12);
  --text: #10261a;
  --muted: #5f6f66;
  --primary: #123524;
  --primary-2: #1f6846;
  --accent: #d98324;
  --danger: #a12b2b;
  --shadow: 0 18px 50px rgba(16, 38, 26, 0.12);
  --radius: 24px;
  --radius-sm: 16px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(217, 131, 36, 0.18), transparent 28%),
    radial-gradient(circle at top right, rgba(31, 104, 70, 0.14), transparent 24%),
    linear-gradient(180deg, #fbf8f2 0%, #f3ede4 100%);
  color: var(--text);
}

body {
  padding: 0;
}

button, input, textarea {
  font: inherit;
}

button, .primary-link {
  border: 0;
  border-radius: 18px;
  padding: 14px 16px;
  min-height: 48px;
  cursor: pointer;
  transition: transform 0.16s ease, opacity 0.16s ease, background 0.16s ease;
}

button:active, .primary-link:active {
  transform: scale(0.98);
}

input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
}

textarea {
  min-height: 110px;
  resize: vertical;
}

.app-shell {
  padding: calc(20px + env(safe-area-inset-top)) 16px calc(104px + env(safe-area-inset-bottom));
  max-width: 760px;
  margin: 0 auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 0 18px;
  backdrop-filter: blur(14px);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  box-shadow: 0 8px 20px rgba(18, 53, 36, 0.16);
}

.brand-logo.large {
  width: 72px;
  height: 72px;
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

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

h1 {
  font-size: 1rem;
}

h2 {
  font-size: 1.2rem;
}

h3 {
  font-size: 1rem;
}

.app-main {
  display: grid;
  gap: 16px;
}

.status-hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.surface {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  padding: 18px;
}

.auth-card {
  display: grid;
  gap: 14px;
}

.auth-screen {
  max-width: 440px;
}

.auth-form {
  width: 100%;
  display: grid;
  gap: 12px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-heading.compact {
  margin-bottom: 10px;
}

.soft-badge, .chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(18, 53, 36, 0.08);
  color: var(--primary);
  font-size: 0.82rem;
}

.button-row {
  display: flex;
  gap: 10px;
}

.button-row.wrap {
  flex-wrap: wrap;
}

.field-stack, .auth-grid, .editor-grid, .stats-grid, .plan-grid {
  display: grid;
  gap: 12px;
}

.auth-grid.compact {
  grid-template-columns: 1fr 1fr 1fr;
}

.editor-grid {
  grid-template-columns: 1fr;
  margin-bottom: 12px;
}

.stats-grid, .plan-grid {
  grid-template-columns: 1fr;
  margin-bottom: 14px;
}

.list-block, .job-list {
  display: grid;
  gap: 10px;
}

.list-item, .job-card, .metric-card, .plan-card, .media-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-strong);
  padding: 14px;
}

.warning-card {
  background: rgba(217, 131, 36, 0.12);
  border-color: rgba(217, 131, 36, 0.3);
}

.list-item header, .media-card header, .job-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.list-meta {
  color: var(--muted);
  font-size: 0.88rem;
  margin-top: 6px;
}

.list-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

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

.secondary {
  background: linear-gradient(135deg, #d98324, #ea9f4d);
  color: #fff;
}

.ghost {
  background: rgba(18, 53, 36, 0.06);
  color: var(--primary);
}

.danger {
  color: #fff;
  background: linear-gradient(135deg, #8f2525, var(--danger));
}

.ghost.danger {
  background: rgba(161, 43, 43, 0.1);
  color: var(--danger);
}

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

.tab-screen {
  display: none;
}

.tab-screen.active {
  display: block;
}

.tabbar {
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  width: min(720px, calc(100% - 24px));
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  padding: 10px;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  box-shadow: 0 18px 48px rgba(16, 38, 26, 0.16);
  backdrop-filter: blur(18px);
  z-index: 30;
}

.tabbar-item {
  min-height: 54px;
  padding: 10px 8px;
  border-radius: 20px;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
}

.tabbar-item.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
}

.avatar, .avatar-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.avatar-button {
  width: 46px;
  height: 46px;
  padding: 0;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 16px;
  background: linear-gradient(135deg, #234c37, #d98324);
  color: #fff;
  font-weight: 700;
}

.avatar-large {
  width: 52px;
  height: 52px;
  border-radius: 18px;
}

.drawer {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 40;
}

.drawer.open {
  display: block;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(16, 38, 26, 0.32);
}

.drawer-panel {
  position: absolute;
  inset: 0 auto 0 0;
  width: min(88vw, 320px);
  background: #fffdf8;
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: calc(24px + env(safe-area-inset-top)) 18px 24px;
  display: grid;
  align-content: start;
  gap: 18px;
}

.drawer-nav {
  display: grid;
  gap: 10px;
}

.drawer-nav button {
  text-align: left;
}

.progress {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: rgba(18, 53, 36, 0.08);
  overflow: hidden;
  margin-top: 12px;
}

.progress > span {
  display: block;
  height: 100%;
  background: linear-gradient(135deg, var(--primary), #4ea16f);
}

.job-log {
  margin-top: 10px;
  padding: 12px;
  border-radius: 16px;
  background: #15231b;
  color: #e7f5ec;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.78rem;
  max-height: 180px;
  overflow: auto;
  white-space: pre-wrap;
}

.editor {
  min-height: 220px;
}

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  left: 50%;
  top: calc(16px + env(safe-area-inset-top));
  transform: translateX(-50%);
  background: #14251c;
  color: #fff;
  border-radius: 999px;
  padding: 12px 16px;
  z-index: 50;
  box-shadow: var(--shadow);
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  text-align: center;
  display: grid;
  gap: 12px;
  justify-items: center;
}

.primary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  text-decoration: none;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
}

.secondary-link {
  background: rgba(18, 53, 36, 0.08);
  color: var(--primary);
}

audio {
  width: 100%;
  margin-top: 12px;
}

@media (min-width: 700px) {
  .auth-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .field-stack {
    grid-template-columns: 1fr 1fr;
  }

  .field-stack textarea,
  .field-stack .button-row,
  .field-stack #linksList {
    grid-column: 1 / -1;
  }

  .editor-grid {
    grid-template-columns: 1fr 1fr;
  }

  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .plan-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 699px) {
  .status-hero {
    align-items: flex-start;
    flex-direction: column;
  }
}
