/* ===========================================================
   Idea Engine — светлая редакционная тема
   Fraunces (антиква, заголовки) + Hanken Grotesk (гротеск, UI)
   Тёплая бумага, чернила, один акцент — глина/терракота.
   =========================================================== */

:root {
  --paper:        #F5F1E8;
  --paper-2:      #EFE9DC;
  --card:         #FFFDF9;
  --ink:          #211E19;
  --ink-soft-c:   #5C554A;
  --ink-faint:    #948C7D;
  --line:         #E5DECE;
  --line-2:       #EEE8DA;
  --accent:       #B0542E;   /* глина */
  --accent-deep:  #8E3F1F;
  --accent-soft:  #F4E5D8;
  --accent-tint:  #FBF1E8;
  --good:         #5E7250;   /* избранное / успех */
  --good-soft:    #E7EBDD;
  --shadow:       0 1px 2px rgba(33,30,25,.04), 0 8px 24px -12px rgba(33,30,25,.18);
  --shadow-lift:  0 2px 6px rgba(33,30,25,.06), 0 18px 40px -16px rgba(33,30,25,.28);
  --radius:       14px;
  --radius-sm:    10px;
  --sans: "Hanken Grotesk", ui-sans-serif, system-ui, sans-serif;
  --serif: "Fraunces", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  /* лёгкая бумажная текстура из двух радиальных бликов */
  background-image:
    radial-gradient(1200px 700px at 88% -10%, #FBF8F1 0%, transparent 55%),
    radial-gradient(900px 600px at -5% 110%, #EFEADf 0%, transparent 50%);
  background-attachment: fixed;
}
::selection { background: var(--accent-soft); }

button { font-family: inherit; cursor: pointer; }
select { font-family: inherit; }
a { color: var(--accent-deep); text-decoration-thickness: 1px; text-underline-offset: 2px; }

.layout { display: grid; grid-template-columns: 290px 1fr; min-height: 100vh; }

/* ===================== Сайдбар ===================== */
.sidebar {
  position: sticky; top: 0; align-self: start;
  height: 100vh; overflow-y: auto;
  padding: 26px 22px;
  background: linear-gradient(180deg, #F2ECDF, #EDE6D6);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 22px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  background: radial-gradient(circle at 32% 30%, #C9744E, var(--accent) 60%, var(--accent-deep));
  box-shadow: inset 0 1px 1px rgba(255,255,255,.4), var(--shadow);
}
.brand-name { font-family: var(--serif); font-weight: 600; font-size: 20px; letter-spacing: -.01em; }
.brand-sub { font-size: 12px; color: var(--ink-faint); letter-spacing: .14em; text-transform: uppercase; margin-top: 1px; }

.project-pick { display: block; }
.project-pick-label { display: block; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 6px; }
#project-select {
  width: 100%; padding: 9px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font-size: 14px; font-weight: 500; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5L6 8l3-3.5' stroke='%23948C7D' stroke-width='1.4' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
}

/* пайплайн-навигация */
.pipeline { display: flex; flex-direction: column; gap: 2px; position: relative; }
.pipeline::before {
  content: ""; position: absolute; left: 18px; top: 22px; bottom: 22px;
  width: 2px; background: linear-gradient(var(--line), transparent);
}
.stage-link {
  position: relative; display: flex; align-items: center; gap: 13px;
  padding: 11px 12px; border: none; background: transparent; width: 100%;
  text-align: left; border-radius: var(--radius-sm); color: var(--ink-soft-c);
  transition: background .15s, color .15s;
}
.stage-link:hover { background: rgba(176,84,46,.06); color: var(--ink); }
.stage-num {
  flex: none; width: 26px; height: 26px; border-radius: 50%; z-index: 1;
  display: grid; place-items: center; font-size: 13px; font-weight: 600;
  background: var(--card); border: 1px solid var(--line); color: var(--ink-faint);
  font-variant-numeric: tabular-nums; transition: all .18s;
}
.stage-link .stage-meta { flex: 1; min-width: 0; }
.stage-link .stage-title { font-weight: 600; font-size: 14px; letter-spacing: -.005em; }
.stage-link .stage-count { font-size: 12px; color: var(--ink-faint); }
.stage-link.active { background: var(--card); box-shadow: var(--shadow); color: var(--ink); }
.stage-link.active .stage-num { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 2px 8px -2px var(--accent); }
.stage-link.active .stage-title { color: var(--accent-deep); }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 9px; padding-top: 14px; border-top: 1px solid var(--line); }
.link-btn {
  background: none; border: none; text-align: left; padding: 4px 2px;
  color: var(--ink-soft-c); font-size: 13px; font-weight: 500;
  border-radius: 6px; transition: color .15s;
}
.link-btn:hover { color: var(--accent-deep); }
.btn-synth {
  margin-top: 4px; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 14px; border-radius: var(--radius-sm);
  background: var(--ink); color: #F3EEE3; border: none; font-weight: 600; font-size: 13.5px;
  transition: transform .12s, box-shadow .2s, background .2s;
}
.btn-synth:hover { background: #2c2820; box-shadow: var(--shadow-lift); transform: translateY(-1px); }
.btn-synth-i { color: var(--accent); font-size: 15px; }
.sidebar-note { font-size: 11.5px; color: var(--ink-faint); line-height: 1.45; margin: 4px 0 0; }

/* ===================== Основная область ===================== */
.main { padding: 0; min-width: 0; }
.stage-head {
  position: sticky; top: 0; z-index: 5;
  padding: 30px 44px 20px;
  background: linear-gradient(var(--paper) 72%, transparent);
  backdrop-filter: blur(2px);
}
.eyebrow { font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: var(--accent); font-weight: 600; }
.stage-h1 { font-family: var(--serif); font-weight: 600; font-size: 34px; line-height: 1.08; letter-spacing: -.02em; margin: 7px 0 0; }
.stage-desc { color: var(--ink-soft-c); max-width: 64ch; margin: 9px 0 0; font-size: 14.5px; }
.stage-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; align-items: center; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 15px; border-radius: 999px; font-size: 13.5px; font-weight: 600;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  transition: transform .12s, box-shadow .2s, border-color .2s, background .2s;
}
.btn:hover { border-color: #d6cdb8; box-shadow: var(--shadow); transform: translateY(-1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-deep); box-shadow: var(--shadow-lift); }
.btn.ghost { background: transparent; }
.btn .ico { font-size: 14px; opacity: .9; }
.btn .tally { font-weight: 700; font-variant-numeric: tabular-nums; opacity: .75; }
.btn:disabled { opacity: .5; box-shadow: none; transform: none; cursor: default; }

.stage-body { padding: 8px 44px 80px; }

/* ===================== Карточки ===================== */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 20px; }
.card {
  position: relative; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px 20px 16px;
  display: flex; flex-direction: column; gap: 12px;
  box-shadow: var(--shadow); transition: box-shadow .22s, transform .22s, border-color .22s;
  animation: rise .5s cubic-bezier(.2,.7,.2,1) both;
}
.card:hover { box-shadow: var(--shadow-lift); transform: translateY(-2px); }
.card.liked { border-color: #d8cdb0; }
.card.liked::before {
  content: ""; position: absolute; left: 0; top: 16px; bottom: 16px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--good);
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.card-tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tag {
  font-size: 11.5px; font-weight: 600; letter-spacing: .01em;
  padding: 3px 9px; border-radius: 999px; white-space: nowrap;
  background: var(--paper-2); color: var(--ink-soft-c); border: 1px solid var(--line-2);
}
.tag.industry { background: var(--accent-tint); color: var(--accent-deep); border-color: var(--accent-soft); }
.tag.angle { background: #efeadc; color: #6b6450; }
.tag.pattern { background: #fff; }
.tag.task { font-variant-numeric: tabular-nums; cursor: help; border-style: dashed; }
.tag.src { margin-left: auto; background: transparent; border: none; color: var(--ink-faint); font-weight: 500; }

.card-title { font-family: var(--serif); font-weight: 600; font-size: 19px; line-height: 1.22; letter-spacing: -.01em; }
.card-title.sm { font-size: 17px; }
.card-sub { font-size: 12.5px; color: var(--ink-faint); margin-top: -6px; font-weight: 500; }
.card-text { color: var(--ink-soft-c); font-size: 14px; }
.card-text .lbl { color: var(--ink-faint); font-weight: 600; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; display: block; margin-bottom: 1px; }
.card-why { background: var(--accent-tint); border-radius: var(--radius-sm); padding: 9px 12px; font-size: 13.5px; color: #6e4a36; }
.card-link { font-size: 13px; font-weight: 600; }

.card-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line-2); display: flex; flex-direction: column; gap: 10px; }
.card-bar { display: flex; align-items: center; gap: 8px; }
.like-btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 13px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink-soft-c);
  font-size: 13px; font-weight: 600; transition: all .16s;
}
.like-btn:hover { border-color: var(--good); color: var(--good); }
.like-btn.on { background: var(--good-soft); border-color: var(--good); color: #3f5235; }
.like-btn .heart { font-size: 13px; }
.expand-btn {
  margin-left: auto; border: none; background: none; color: var(--accent-deep);
  font-size: 13px; font-weight: 600; padding: 6px 4px;
}
.expand-btn:hover { text-decoration: underline; }

/* комментарии под карточкой */
.comments { display: flex; flex-direction: column; gap: 7px; }
.comment {
  display: flex; gap: 8px; align-items: flex-start;
  background: var(--paper); border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  padding: 7px 9px 7px 11px; font-size: 13px; color: var(--ink-soft-c);
}
.comment .c-txt { flex: 1; }
.comment .c-del { border: none; background: none; color: var(--ink-faint); font-size: 14px; line-height: 1; padding: 0 2px; }
.comment .c-del:hover { color: var(--accent); }
.comment-add { display: flex; gap: 8px; }
.comment-add input {
  flex: 1; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 8px 11px; font-family: inherit; font-size: 13px; background: var(--paper); color: var(--ink);
  transition: border-color .15s, background .15s;
}
.comment-add input::placeholder { color: var(--ink-faint); }
.comment-add input:focus { outline: none; border-color: var(--accent); background: #fff; }
.comment-add button {
  border: none; background: var(--accent-tint); color: var(--accent-deep);
  border-radius: var(--radius-sm); padding: 0 13px; font-weight: 700; font-size: 16px;
}
.comment-add button:hover { background: var(--accent-soft); }

/* группировка идей по метафорам */
.metaphor-group { margin-bottom: 34px; }
.mg-head { display: flex; align-items: baseline; gap: 12px; margin: 0 0 14px; padding-bottom: 10px; border-bottom: 2px solid var(--line); }
.mg-kicker { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); font-weight: 600; }
.mg-title { font-family: var(--serif); font-weight: 600; font-size: 23px; letter-spacing: -.01em; }
.mg-count { font-size: 13px; color: var(--ink-faint); margin-left: auto; }

/* панель бренда (этап концептов) */
.brand-panel {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 22px; box-shadow: var(--shadow);
  display: grid; grid-template-columns: 1fr 1fr auto; gap: 12px 16px; align-items: end;
}
.brand-panel.warn { border-color: var(--accent); background: var(--accent-tint); }
.brand-head { grid-column: 1 / -1; display: flex; align-items: baseline; gap: 12px; }
.brand-head b { font-family: var(--serif); font-size: 17px; }
.brand-warn { color: var(--accent-deep); font-size: 12.5px; }
.brand-field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--ink-faint); }
.brand-field input {
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px 11px;
  font: inherit; font-size: 14px; background: var(--paper); color: var(--ink);
}
.brand-field input:focus { outline: none; border-color: var(--accent); background: #fff; }
.brand-readout {
  background: var(--accent-tint); border: 1px solid var(--accent-soft);
  border-radius: var(--radius-sm); padding: 9px 12px; font-size: 13px; color: #6e4a36; margin-bottom: 12px;
}
@media (max-width: 680px) { .brand-panel { grid-template-columns: 1fr; } }

/* референсы стиля на карточке концепта */
.sr-empty { font-size: 12.5px; color: var(--ink-faint); font-style: italic; padding: 4px 0; }
.style-refs { border-top: 1px solid var(--line-2); padding-top: 11px; }
.sr-label { font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-faint); font-weight: 600; margin-bottom: 8px; }
.sr-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sr {
  display: flex; flex-direction: column; text-align: left; cursor: pointer;
  border: 1.5px solid var(--line); border-radius: var(--radius-sm); overflow: hidden;
  background: var(--paper); padding: 0; transition: border-color .15s, box-shadow .15s, transform .12s;
}
.sr:hover { border-color: var(--accent); transform: translateY(-1px); }
.sr.sel { border-color: var(--accent); box-shadow: inset 0 0 0 1.5px var(--accent); }
.sr-thumb { position: relative; aspect-ratio: 16/10; background: var(--paper-2); display: block; }
.sr-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.sr-dom { position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; color: var(--ink-faint); }
.sr-cap { padding: 7px 9px; font-size: 12px; display: flex; flex-direction: column; gap: 2px; }
.sr-cap b { font-size: 12.5px; line-height: 1.2; }
.sr-cap i { color: var(--ink-faint); font-style: normal; font-size: 11.5px; }
.sr-cap a { font-size: 11.5px; font-weight: 600; }
.sr-pick { margin-top: auto; text-align: center; font-size: 11px; font-weight: 700; padding: 5px; color: var(--ink-faint); border-top: 1px solid var(--line-2); }
.sr.sel .sr-pick { color: var(--accent-deep); background: var(--accent-tint); }

/* кнопка мокапа — отдельным рядом, выше блоков референсов */
.mockup-row { margin-top: 2px; }
.mockup-open { width: 100%; justify-content: center; }

/* визуальные стили — мультивыбор чипами */
.styles { border-top: 1px solid var(--line-2); padding-top: 11px; }
.style-list { display: flex; flex-direction: column; gap: 7px; }
.style-chip {
  border: 1.5px solid var(--line); border-radius: var(--radius-sm); padding: 8px 11px;
  cursor: pointer; background: var(--paper); transition: border-color .15s, background .15s;
}
.style-chip:hover { border-color: var(--accent); }
.style-chip.sel { border-color: var(--accent); background: var(--accent-tint); }
.style-name { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13.5px; }
.style-box {
  width: 16px; height: 16px; border-radius: 4px; border: 1.5px solid var(--line);
  display: inline-grid; place-items: center; font-size: 11px; color: #fff; flex: none;
}
.style-chip.sel .style-box { background: var(--accent); border-color: var(--accent); }
.style-note { font-size: 12px; color: var(--ink-soft-c); margin: 3px 0 0 24px; }
.style-links { display: flex; flex-wrap: wrap; gap: 10px; margin: 5px 0 0 24px; }
.style-links a { font-size: 12px; font-weight: 600; }

/* мокап (iframe wireframe) */
.mockup { border-top: 1px solid var(--line-2); padding-top: 11px; }
.mockup-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 7px; }
.mockup-head span { font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-faint); font-weight: 600; }
.mockup-frame {
  width: 100%; height: 240px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: #fff; display: block;
}
.mockup-frame.big { height: 64vh; }

/* пустые состояния */
.empty {
  text-align: center; padding: 70px 30px; color: var(--ink-faint);
  border: 1.5px dashed var(--line); border-radius: var(--radius); background: rgba(255,253,249,.5);
}
.empty .e-mark { font-size: 30px; }
.empty h3 { font-family: var(--serif); font-weight: 600; color: var(--ink-soft-c); margin: 12px 0 4px; font-size: 19px; }
.empty p { max-width: 46ch; margin: 0 auto; font-size: 14px; }

/* ===================== Модалки ===================== */
.sheet-root.open { position: fixed; inset: 0; z-index: 50; overflow-y: auto; }
.veil { position: fixed; inset: 0; background: rgba(33,30,25,.42); backdrop-filter: blur(3px); animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: relative; z-index: 1; box-sizing: border-box;
  margin: 6vh auto; max-width: 760px; width: calc(100% - 36px);
  background: var(--card);
  border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-lift);
  padding: 26px 28px; animation: pop .26s cubic-bezier(.2,.7,.2,1);
}
.sheet.wide { max-width: 920px; }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.99); } }
.sheet h2 { font-family: var(--serif); font-weight: 600; font-size: 25px; margin: 0 0 4px; letter-spacing: -.01em; }
.sheet .m-sub { color: var(--ink-faint); font-size: 13.5px; margin-bottom: 16px; }
.sheet-x { position: absolute; top: 16px; right: 18px; border: none; background: none; font-size: 22px; color: var(--ink-faint); line-height: 1; }
.sheet-x:hover { color: var(--ink); }

/* промпт-просмотр */
.prompt-box {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 16px; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px;
  line-height: 1.55; white-space: pre-wrap; word-break: break-word; max-height: 50vh; overflow: auto; color: #3f3a31;
}
.sheet-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* рендер markdown (концепт, rules, бриф) */
.md { font-size: 14.5px; color: var(--ink-soft-c); line-height: 1.6; max-height: 64vh; overflow: auto; padding-right: 6px; }
.md h1 { font-family: var(--serif); font-size: 26px; color: var(--ink); margin: 0 0 6px; letter-spacing: -.01em; }
.md h2 { font-family: var(--serif); font-size: 19px; color: var(--accent-deep); margin: 22px 0 6px; }
.md h3 { font-size: 15px; color: var(--ink); margin: 16px 0 4px; }
.md blockquote { border-left: 3px solid var(--accent-soft); margin: 8px 0; padding: 2px 0 2px 14px; color: var(--ink-faint); font-style: italic; }
.md ul { padding-left: 20px; } .md li { margin: 3px 0; }
.md p { margin: 7px 0; }
.md code { background: var(--paper-2); padding: 1px 5px; border-radius: 5px; font-size: 12.5px; }
.md strong { color: var(--ink); }

/* ===================== Тост ===================== */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px);
  background: var(--ink); color: #F3EEE3; padding: 11px 20px; border-radius: 999px;
  font-size: 13.5px; font-weight: 500; box-shadow: var(--shadow-lift);
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; z-index: 80;
  max-width: 80vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--accent-deep); }
.toast .t-i { color: var(--accent); margin-right: 6px; }
.toast.err .t-i { color: #f3d3c4; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .pipeline { flex-direction: row; flex-wrap: wrap; }
  .pipeline::before { display: none; }
  .stage-head, .stage-body { padding-left: 20px; padding-right: 20px; }
}
