:root {
  color-scheme: light;
  --bg: #f7f7f2;
  --panel: #ffffff;
  --ink: #191a1d;
  --muted: #666b73;
  --line: #d9dcd2;
  --accent: #176b5d;
  --accent-ink: #ffffff;
  --danger: #a9332b;
  --shadow: 0 10px 30px rgba(25, 26, 29, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100svh;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: calc(16px + env(safe-area-inset-top)) 16px 12px;
  background: rgba(247, 247, 242, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.eyebrow,
.label,
.small-muted {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.15;
}

h2 {
  font-size: 17px;
  line-height: 1.2;
}

.layout {
  width: min(100%, 820px);
  margin: 0 auto;
  padding: 14px 12px calc(28px + env(safe-area-inset-bottom));
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 12px;
}

.status-panel,
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.status-text {
  margin-top: 2px;
  font-size: 15px;
  font-weight: 700;
}

.small-muted {
  margin-top: 3px;
  font-weight: 700;
  text-transform: none;
}

.stack {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

textarea,
input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbf8;
  color: var(--ink);
  padding: 12px;
  outline: none;
}

textarea {
  min-height: 170px;
  resize: vertical;
  line-height: 1.5;
}

textarea:focus,
input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 107, 93, 0.14);
}

.count {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.segmented button {
  min-height: 44px;
  border: 0;
  background: #f2f3ee;
  color: var(--muted);
  font-weight: 800;
}

.segmented button + button {
  border-left: 1px solid var(--line);
}

.segmented .active {
  background: var(--ink);
  color: #ffffff;
}

.primary,
.secondary,
.icon-button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 850;
}

.primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.secondary,
.icon-button {
  background: #ffffff;
  border-color: var(--line);
  color: var(--ink);
}

.icon-button {
  width: 44px;
  padding: 0;
  font-size: 20px;
}

button:disabled {
  cursor: progress;
  opacity: 0.6;
}

.posts-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.metric {
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbf8;
  padding: 12px;
}

.metric-value {
  margin-top: 4px;
  color: var(--ink);
  font-size: 24px;
  font-weight: 900;
  line-height: 1;
}

.top-posts-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.metric-chip {
  border-radius: 8px;
  background: #eef3ef;
  padding: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.metric-chip strong {
  display: block;
  margin-top: 2px;
  color: var(--ink);
  font-size: 16px;
}

.post-item {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfbf8;
}

.post-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.post-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.45;
  font-size: 14px;
}

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

.empty {
  color: var(--muted);
  padding: 12px 0 2px;
  text-align: center;
}

.toast {
  position: fixed;
  right: 12px;
  bottom: calc(14px + env(safe-area-inset-bottom));
  left: 12px;
  z-index: 10;
  max-width: 520px;
  margin: 0 auto;
  border-radius: 8px;
  background: var(--ink);
  color: #ffffff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  font-size: 14px;
  font-weight: 700;
}

.callback-layout {
  width: min(100%, 560px);
  min-height: 100svh;
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) 12px calc(28px + env(safe-area-inset-bottom));
  display: grid;
  align-items: center;
}

.callback-copy {
  margin: 14px 0;
  color: var(--muted);
  line-height: 1.55;
}

.token-output {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfbf8;
  padding: 12px;
  color: var(--ink);
}

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 12px;
  text-decoration: none;
}

.hidden {
  display: none !important;
}

@media (min-width: 760px) {
  .layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: start;
    gap: 14px;
    padding-top: 20px;
  }

  .panel {
    margin-bottom: 0;
  }

  .status-panel,
  .composer,
  .analytics-panel {
    grid-column: 1;
  }

  .queue-panel {
    grid-column: 2;
    grid-row: span 2;
  }
}
