:root {
  --paper: #faf6ef;
  --card: #ffffff;
  --ink: #2b2521;
  --ink-soft: #6f6459;
  --accent: #c4552d;
  --accent-soft: #f3e2d8;
  --gold: #b98a2f;
  --line: #e8dfd3;
  --radius: 16px;
  --shadow: 0 2px 12px rgba(60, 45, 30, 0.08);
  font-size: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, .brand, .draft-title, .art-title { font-family: Georgia, "Times New Roman", serif; }

.top {
  padding: 14px 20px 10px;
  text-align: center;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}
.brand { font-size: 1.25rem; letter-spacing: 0.02em; }
.brand span { color: var(--accent); }
.brand-sub { font-size: 0.72rem; color: var(--ink-soft); margin-top: 2px; letter-spacing: 0.04em; }

#app {
  flex: 1;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 16px 90px;
}

.screen { display: none; }
.screen.active { display: block; animation: fade 0.25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.hidden { display: none !important; }

/* ---- старт ---- */
.spark-badge {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem; margin: 18px auto 16px;
  box-shadow: var(--shadow);
}
#screen-start h1 { text-align: center; font-size: 1.6rem; line-height: 1.25; margin-bottom: 12px; }
.lead { text-align: center; color: var(--ink-soft); line-height: 1.5; margin-bottom: 24px; }

.start-input textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  padding: 14px;
  font: inherit;
  resize: vertical;
  box-shadow: var(--shadow);
}
.start-actions { display: flex; gap: 10px; margin-top: 12px; }
.start-actions .primary { flex: 1; }

/* ---- кнопки ---- */
button { font: inherit; cursor: pointer; border: none; -webkit-tap-highlight-color: transparent; }

.primary {
  background: var(--accent); color: #fff;
  border-radius: var(--radius);
  padding: 13px 20px;
  font-weight: 600;
  transition: transform 0.1s ease, opacity 0.2s;
}
.primary:active { transform: scale(0.97); }
.primary:disabled { opacity: 0.5; }
.primary.wide { width: 100%; }
.primary.round { border-radius: 50%; width: 48px; height: 48px; padding: 0; flex-shrink: 0; }

.ghost {
  background: transparent; color: var(--accent);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 18px; font-weight: 600;
}
.ghost.small { padding: 6px 12px; font-size: 0.85rem; margin-bottom: 14px; }

.mic-btn {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--card); border: 1.5px solid var(--line);
  font-size: 1.25rem; flex-shrink: 0;
  box-shadow: var(--shadow);
  transition: all 0.2s;
}
.mic-btn.recording {
  background: var(--accent); border-color: var(--accent);
  animation: pulse 1.2s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(196, 85, 45, 0.35); }
  50% { box-shadow: 0 0 0 12px rgba(196, 85, 45, 0); }
}
.mic-hint { text-align: center; color: var(--accent); font-size: 0.85rem; margin-top: 8px; }

/* ---- чат ---- */
.chat-log { display: flex; flex-direction: column; gap: 12px; padding-bottom: 16px; }
.msg {
  max-width: 85%;
  padding: 12px 15px;
  border-radius: var(--radius);
  line-height: 1.5;
  white-space: pre-wrap;
  animation: fade 0.25s ease;
}
.msg.iskra {
  background: var(--card);
  border: 1px solid var(--line);
  align-self: flex-start;
  box-shadow: var(--shadow);
  border-bottom-left-radius: 4px;
}
.msg.user {
  background: var(--accent-soft);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.msg.iskra::before {
  content: "✦ Искра";
  display: block;
  font-size: 0.72rem;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 4px;
  letter-spacing: 0.03em;
}

.chat-input {
  display: flex; gap: 8px; align-items: flex-end;
  position: sticky; bottom: 84px;
  background: var(--paper);
  padding-top: 8px;
}
.chat-input textarea {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  padding: 12px;
  font: inherit;
  resize: none;
  box-shadow: var(--shadow);
}

.draft-ready { margin: 6px 0 14px; }

/* ---- черновик ---- */
.draft-meta { display: flex; gap: 8px; margin-bottom: 12px; }
.chip {
  background: var(--accent); color: #fff;
  font-size: 0.75rem; font-weight: 600;
  padding: 5px 12px; border-radius: 999px;
}
.chip-soft { background: var(--accent-soft); color: var(--accent); }

.draft-title {
  width: 100%; font-size: 1.35rem; font-weight: 700;
  border: none; border-bottom: 2px solid var(--line);
  background: transparent; padding: 8px 2px; margin-bottom: 14px;
  color: var(--ink);
}
.draft-title:focus { outline: none; border-color: var(--accent); }

.draft-text {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  padding: 16px;
  font: inherit; line-height: 1.6;
  resize: vertical;
  box-shadow: var(--shadow);
}
.draft-actions { display: flex; gap: 10px; margin-top: 14px; }
.draft-actions button { flex: 1; }

.mirror-panel {
  margin-top: 20px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.mirror-head { font-weight: 700; color: var(--gold); margin-bottom: 8px; letter-spacing: 0.03em; }
.mirror-summary { font-style: italic; margin-bottom: 14px; line-height: 1.5; }
.mirror-dim { margin-bottom: 12px; }
.mirror-dim b { display: block; font-size: 0.85rem; color: var(--accent); margin-bottom: 3px; }
.mirror-dim p { color: var(--ink); line-height: 1.5; font-size: 0.95rem; }
.mirror-note { font-size: 0.8rem; color: var(--ink-soft); margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 10px; }

/* ---- каталог ---- */
.cat-head { margin-bottom: 16px; font-size: 1.35rem; }
.catalog-list { display: flex; flex-direction: column; gap: 12px; }
.cat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.1s;
}
.cat-card:active { transform: scale(0.99); }
.cat-card .chip { font-size: 0.68rem; padding: 3px 10px; }
.cat-card h3 { font-family: Georgia, serif; margin: 8px 0 6px; font-size: 1.1rem; line-height: 1.3; }
.cat-card .prev { color: var(--ink-soft); font-size: 0.9rem; line-height: 1.45; }
.cat-card .who { margin-top: 10px; font-size: 0.8rem; color: var(--accent); font-weight: 600; }
.cat-empty { text-align: center; color: var(--ink-soft); padding: 40px 20px; line-height: 1.6; }

/* ---- статья ---- */
.art-meta { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.art-date { font-size: 0.8rem; color: var(--ink-soft); }
.art-title { font-size: 1.5rem; line-height: 1.25; margin-bottom: 8px; }
.art-author { color: var(--accent); font-weight: 600; font-size: 0.9rem; margin-bottom: 18px; }
.art-body { line-height: 1.65; }
.art-body h2 { font-size: 1.15rem; margin: 20px 0 8px; }
.art-body p { margin-bottom: 12px; }

/* ---- загрузка ---- */
.loading {
  position: fixed; inset: 0;
  background: rgba(250, 246, 239, 0.88);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 50;
}
.flame { font-size: 2.2rem; color: var(--accent); animation: flick 1s infinite alternate; }
@keyframes flick { from { transform: scale(1); opacity: 0.7; } to { transform: scale(1.2); opacity: 1; } }
#loading-text { margin-top: 10px; color: var(--ink-soft); }

/* ---- фото ---- */
.photo-row { margin-top: 12px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.photo-preview { max-height: 90px; border-radius: 10px; border: 1px solid var(--line); }
.art-photo { width: 100%; border-radius: var(--radius); margin-bottom: 16px; box-shadow: var(--shadow); }

/* ---- отправлено ---- */
.sent-link-box {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
  margin-top: 8px;
}
.sent-link-label { font-size: 0.85rem; color: var(--ink-soft); margin-bottom: 8px; }
.sent-link {
  width: 100%; font-size: 0.8rem; padding: 10px;
  border: 1px dashed var(--line); border-radius: 10px;
  background: var(--paper); color: var(--ink); margin-bottom: 10px;
}
.small-note { font-size: 0.8rem; margin-top: 12px; }

/* ---- рецензирование ---- */
.rev-name-row { margin-bottom: 14px; }
.rev-name {
  width: 100%; padding: 12px; font: inherit;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); box-shadow: var(--shadow);
}
.matrix { margin-top: 24px; border-top: 2px solid var(--line); padding-top: 18px; }
.matrix-head { font-family: Georgia, serif; font-size: 1.15rem; margin-bottom: 6px; }
.matrix-sub { color: var(--ink-soft); font-size: 0.85rem; margin-bottom: 16px; }
.matrix-item { margin-bottom: 14px; }
.matrix-item b { display: block; font-size: 0.95rem; }
.matrix-item span { display: block; font-size: 0.8rem; color: var(--ink-soft); margin: 2px 0 6px; }
.stars { display: flex; gap: 6px; }
.star {
  font-size: 1.5rem; background: none; color: var(--line);
  padding: 2px 4px; transition: color 0.15s;
}
.star.on { color: var(--gold); }
.matrix .draft-text { margin-top: 8px; }

/* ---- статус материала ---- */
.status-banner {
  border-radius: var(--radius); padding: 16px; margin-bottom: 18px;
  line-height: 1.5; box-shadow: var(--shadow);
}
.st-review { background: #fdf3dc; border: 1px solid #ecd9a8; }
.st-revision { background: var(--accent-soft); border: 1px solid #e6c3b2; }
.st-published { background: #e8f2e2; border: 1px solid #c4dcb6; }
.review-card {
  background: var(--card); border: 1px solid var(--line);
  border-left: 4px solid var(--gold);
  border-radius: 12px; padding: 14px; margin-bottom: 10px;
  line-height: 1.5;
}
.review-card.rv-accept { border-left-color: #7aa864; }
.review-card.rv-revise { border-left-color: var(--accent); }
.rv-verdict { font-size: 0.8rem; font-weight: 700; color: var(--ink-soft); margin-bottom: 6px; }

/* ---- таббар ---- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  gap: 8px;
  z-index: 40;
}
.tab {
  flex: 1;
  background: transparent;
  border-radius: 12px;
  padding: 11px;
  font-weight: 600;
  color: var(--ink-soft);
}
.tab.active { background: var(--accent-soft); color: var(--accent); }
