:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --hover: #e9f5fc;
  --button-soft: #e9f5fc;
  --button-active: #d9f0fb;
  --danger-soft: #feecec;
  --line: #d9e2ec;
  --text: #17212b;
  --text-soft: #253746;
  --muted: #607284;
  --blue: #229ed9;
  --blue-strong: #168acd;
  --green: #2ba84a;
  --red: #d84a4a;
  --shadow: 0 8px 28px rgba(39, 67, 93, 0.08);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1419;
  --panel: #17212b;
  --panel-soft: #1f2c37;
  --hover: #21384a;
  --button-soft: #1e394c;
  --button-active: #224c66;
  --danger-soft: #3a2025;
  --line: #2b3a46;
  --text: #edf4fa;
  --text-soft: #d7e2ea;
  --muted: #94a8b8;
  --blue: #2ea6de;
  --blue-strong: #5bbbe6;
  --green: #57c785;
  --red: #ff7b7b;
  --shadow: 0 10px 32px rgba(0, 0, 0, 0.24);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

a {
  color: var(--blue-strong);
  text-decoration: none;
}

.app-shell {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  align-items: center;
  display: flex;
  gap: 10px;
  margin: 0 4px 20px;
}

.brand-mark {
  align-items: center;
  background: var(--blue);
  border-radius: 8px;
  color: white;
  display: inline-flex;
  font-weight: 800;
  height: 36px;
  justify-content: center;
  width: 36px;
}

.brand-title {
  font-size: 18px;
  font-weight: 750;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.nav {
  display: grid;
  gap: 4px;
}

.nav button {
  align-items: center;
  background: transparent;
  border-radius: 8px;
  color: var(--text);
  display: flex;
  gap: 10px;
  min-height: 40px;
  padding: 8px 10px;
  text-align: left;
}

.nav button.active,
.nav button:hover {
  background: var(--hover);
  color: var(--blue-strong);
}

.main {
  min-width: 0;
  padding: 22px;
}

.topbar {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 18px;
}

.page-title {
  font-size: 24px;
  font-weight: 760;
  margin: 0;
}

.user-chip {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 10px;
  min-height: 38px;
  padding: 7px 10px;
}

.grid {
  display: grid;
  gap: 14px;
}

.overview {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.metric-value {
  font-size: 22px;
  font-weight: 780;
}

.metric-label,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.content-layout {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1fr) 340px;
}

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

.panel h2 {
  font-size: 16px;
  margin: 0 0 12px;
}

.card-list {
  display: grid;
  gap: 10px;
}

.post-card,
.story-card,
.digest-card,
.rule-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
}

.card-head {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  margin-bottom: 8px;
}

.source {
  color: var(--blue-strong);
  font-weight: 700;
}

.time {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.post-title {
  font-weight: 730;
  margin-bottom: 6px;
}

.post-text {
  color: var(--text-soft);
  font-size: 14px;
  line-height: 1.42;
  white-space: pre-wrap;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.tag {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  padding: 4px 8px;
}

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

.btn {
  align-items: center;
  background: var(--button-soft);
  border-radius: 8px;
  color: var(--blue-strong);
  display: inline-flex;
  gap: 6px;
  min-height: 34px;
  padding: 7px 10px;
}

.btn.primary {
  background: var(--blue);
  color: white;
}

.btn.danger {
  background: var(--danger-soft);
  color: var(--red);
}

.btn.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
}

.btn.active {
  background: var(--button-active);
  box-shadow: inset 0 0 0 1px var(--blue);
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
}

.input,
.textarea,
.select {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 38px;
  padding: 8px 10px;
  width: 100%;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--muted);
}

.textarea {
  min-height: 92px;
  resize: vertical;
}

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

.split.compact {
  align-items: end;
  grid-template-columns: minmax(0, 1fr) auto;
}

.empty,
.error,
.notice {
  background: var(--panel);
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 18px;
  text-align: center;
}

.error {
  border-color: #f2b8b8;
  color: var(--red);
}

.notice {
  border-color: color-mix(in srgb, var(--green) 42%, var(--line));
  color: var(--green);
  margin-bottom: 12px;
}

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

.login-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin: 0 auto;
  max-width: 420px;
  padding: 22px;
  width: 100%;
}

.login-box h1 {
  margin: 0 0 8px;
}

.login-controls {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-bottom: 18px;
}

.login-fallback {
  display: grid;
  gap: 10px;
  justify-items: start;
  margin-top: 16px;
}

.login-notice {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 34%, var(--line));
  border-radius: 8px;
  color: var(--text);
  display: grid;
  gap: 4px;
  margin-top: 16px;
  padding: 12px;
}

.login-notice span {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.login-fallback .muted {
  margin: 0;
}

.status {
  color: var(--muted);
  font-size: 13px;
  margin-top: 12px;
}

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

.onboarding-shell {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin: 0 auto;
  max-width: 680px;
  padding: 22px;
  width: 100%;
}

.onboarding-step h1 {
  font-size: 28px;
  line-height: 1.15;
  margin: 0 0 10px;
}

.progress {
  background: var(--panel-soft);
  border-radius: 999px;
  height: 8px;
  margin: 4px 0 22px;
  overflow: hidden;
}

.progress span {
  background: var(--blue);
  display: block;
  height: 100%;
  transition: width 180ms ease;
}

.signal {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 16px;
  padding: 12px;
}

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

.option {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  display: grid;
  gap: 5px;
  min-height: 58px;
  padding: 12px;
  text-align: left;
}

.option:hover {
  background: var(--hover);
  border-color: var(--blue);
}

.option span {
  color: var(--muted);
  font-size: 13px;
}

.demo-card {
  margin-top: 16px;
}

.timeline-panel {
  align-self: start;
  max-height: calc(100vh - 44px);
  overflow: auto;
}

.timeline-list {
  display: grid;
  gap: 10px;
}

.timeline-item {
  border-left: 3px solid var(--blue);
  padding-left: 10px;
}

.subhead {
  margin-top: 16px !important;
}

.rule-list {
  display: grid;
  gap: 10px;
}

.lock-note {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  margin: 12px 0;
  padding: 12px;
}

.lock-note span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.delivery-panel {
  align-self: start;
  display: grid;
  gap: 10px;
}

.status-pill {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 8px 10px;
}

.status-pill.ok {
  border-color: color-mix(in srgb, var(--green) 45%, var(--line));
  color: var(--green);
}

.delivery-targets {
  display: grid;
  gap: 8px;
}

.delivery-targets div {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 2px;
  padding: 10px;
}

.delivery-targets span,
.faq-card p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.faq-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.faq-card h3 {
  font-size: 15px;
  margin: 0 0 8px;
}

.support-panel {
  align-self: start;
  display: grid;
  gap: 10px;
}

.topbar-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.segmented {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: inline-flex;
  min-height: 36px;
  overflow: hidden;
}

.segmented.wide {
  width: 100%;
}

.segmented button {
  background: transparent;
  color: var(--muted);
  min-height: 34px;
  padding: 7px 10px;
}

.segmented.wide button {
  flex: 1;
}

.segmented button.active,
.segmented button:hover {
  background: var(--hover);
  color: var(--blue-strong);
}

.icon-btn {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  display: inline-flex;
  font-size: 16px;
  height: 36px;
  justify-content: center;
  width: 36px;
}

.icon-btn:hover {
  background: var(--hover);
}

@media (max-width: 900px) {
  .app-shell {
    display: block;
    padding-bottom: 62px;
  }

  .sidebar {
    border-right: 0;
    border-top: 1px solid var(--line);
    bottom: 0;
    height: 62px;
    left: 0;
    padding: 6px;
    position: fixed;
    right: 0;
    top: auto;
    z-index: 20;
  }

  .brand {
    display: none;
  }

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

  .nav button {
    display: grid;
    font-size: 11px;
    gap: 2px;
    justify-items: center;
    min-height: 48px;
    padding: 4px 2px;
  }

  .main {
    padding: 14px;
  }

  .topbar {
    align-items: flex-start;
    display: grid;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

	  .overview,
	  .content-layout,
	  .split {
	    grid-template-columns: 1fr;
	  }

  .option-grid,
  .split.compact {
    grid-template-columns: 1fr;
  }
}
