:root {
  color-scheme: dark;
  --bg: #101114;
  --panel: #181a1f;
  --panel-strong: #202329;
  --line: #30343b;
  --text: #f3f1ea;
  --muted: #a7a49d;
  --accent: #31c48d;
  --accent-strong: #24a876;
  --warn: #f2b84b;
  --danger: #e45a4f;
  --shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

body {
  font-size: 16px;
  line-height: 1.45;
}

button,
select,
textarea {
  font: inherit;
}

.app-shell {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 16px max(22px, env(safe-area-inset-bottom));
}

.topbar,
.section-head,
.composer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.topbar {
  padding: 6px 0 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.1;
}

h2 {
  font-size: 18px;
}

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

.icon-button {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 14px;
}

.status-strip > div {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.status-strip span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.status-strip strong {
  display: block;
  margin-top: 2px;
  font-size: 22px;
}

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

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

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

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

select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--text);
  outline: none;
}

select {
  height: 44px;
  padding: 0 12px;
}

textarea {
  min-height: 170px;
  max-height: 420px;
  resize: vertical;
  padding: 12px;
}

select:focus,
textarea:focus {
  border-color: var(--accent);
}

.primary-button,
.secondary-button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 800;
  cursor: pointer;
}

.primary-button {
  background: var(--accent);
  color: #07110d;
}

.primary-button:disabled,
.secondary-button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--text);
}

.status-text {
  min-height: 22px;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.draft-text {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  margin-top: 12px;
  padding: 14px;
  border-radius: 8px;
  background: #111317;
  color: var(--text);
}

.drafts {
  margin-top: 14px;
  box-shadow: none;
}

.draft-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.draft-item {
  display: grid;
  gap: 7px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}

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

.draft-snippet {
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  color: var(--text);
}

.empty-state {
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.blocking-state {
  width: min(480px, calc(100% - 32px));
  margin: 20vh auto 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  text-align: center;
}

.blocking-state p {
  margin: 8px 0 0;
  color: var(--muted);
}

@media (min-width: 860px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr) minmax(320px, 0.72fr);
    align-items: start;
  }
}

@media (max-width: 620px) {
  .app-shell {
    padding-left: 12px;
    padding-right: 12px;
  }

  h1 {
    font-size: 25px;
  }

  .field-row,
  .status-strip {
    grid-template-columns: 1fr;
  }

  .composer-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .status-text {
    text-align: left;
  }
}
