/* ===========================================================
   IncendiuABC — token system
   Paper/ink/stamp aesthetic drawn from Monitorul Oficial pages
   and the ring-binder tabs ISU/PSI officers actually use.
   =========================================================== */
:root {
  --ink: #1c2b39;
  --ink-soft: #3a4a58;
  --paper: #eeebe1;
  --paper-raised: #f7f5ee;
  --paper-deep: #e4e0d2;
  --line: #c9c3b1;
  --line-soft: #ddd8c8;
  --red: #ab241d;
  --red-deep: #7e1a15;
  --brass: #93752f;
  --ok: #3f6b4a;
  --warn: #a3671a;
  --focus: #2f6fb3;

  --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --font-body: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --radius: 3px;
  --shadow-card: 0 1px 0 rgba(28, 43, 57, 0.06), 0 1px 3px rgba(28, 43, 57, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
}

::selection { background: #f0d9b5; }

a { color: var(--focus); }

button {
  font-family: inherit;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* -------------------- layout shell -------------------- */
.app-shell {
  display: grid;
  grid-template-columns: 250px 1fr;
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "topbar topbar"
    "rail   main";
  height: 100vh;
  min-height: 100vh;
}

@media (max-width: 880px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      "topbar"
      "rail"
      "main";
    height: auto;
    min-height: 100vh;
  }
  .rail { flex-direction: row !important; overflow-x: auto; height: auto !important; }
  .rail .tab-label small { display: none; }
}

/* -------------------- top bar -------------------- */
.topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 20px;
  background: var(--ink);
  color: var(--paper-raised);
  border-bottom: 3px solid var(--red);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 20px;
  letter-spacing: 0.2px;
  white-space: nowrap;
}
.brand .seal {
  width: 30px; height: 30px;
  flex: none;
}
.brand small {
  display: block;
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 10.5px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: #c9b98f;
}

.search-wrap {
  flex: 1;
  max-width: 520px;
  position: relative;
}
.search-wrap input {
  width: 100%;
  padding: 8px 12px 8px 34px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: rgba(255,255,255,0.1);
  color: var(--paper-raised);
  font-family: var(--font-body);
  font-size: 13.5px;
}
.search-wrap input::placeholder { color: #b7c2cb; }
.search-wrap input:focus { background: var(--paper-raised); color: var(--ink); outline: none; border-color: var(--brass);}
.search-wrap .icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  font-size: 14px; opacity: 0.7; pointer-events: none;
}

.profile-select {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
}
.profile-select select {
  background: rgba(255,255,255,0.08);
  color: var(--paper-raised);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: var(--radius);
  padding: 6px 8px;
  font-family: var(--font-body);
  font-size: 12.5px;
}
.profile-select select option { color: var(--ink); }

.ai-toggle {
  background: var(--red);
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.2px;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.ai-toggle:hover { background: var(--red-deep); }

/* -------------------- rail (binder tabs) -------------------- */
.rail {
  grid-area: rail;
  background: var(--paper-deep);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 14px 0;
  overflow-y: auto;
}

.tab {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border: none;
  background: transparent;
  text-align: left;
  color: var(--ink-soft);
  border-left: 4px solid transparent;
  font-size: 13.5px;
}
.tab .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--line); }
.tab.active {
  background: var(--paper-raised);
  border-left-color: var(--red);
  color: var(--ink);
  font-weight: 600;
  box-shadow: var(--shadow-card);
}
.tab:hover:not(.active) { background: rgba(255,255,255,0.4); }
.tab-label { display: flex; flex-direction: column; }
.tab-label small { font-weight: 400; color: var(--ink-soft); font-size: 11px; }

.rail-section-title {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--brass);
  padding: 14px 16px 6px;
}

.rail-footer {
  margin-top: auto;
  padding: 12px 16px;
  font-size: 11px;
  color: var(--ink-soft);
  border-top: 1px solid var(--line);
}

/* -------------------- main area -------------------- */
.main {
  grid-area: main;
  overflow-y: auto;
  padding: 26px 34px 60px;
}

.view-header {
  margin-bottom: 20px;
}
.view-header h1 {
  font-family: var(--font-display);
  font-size: 27px;
  margin: 0 0 4px;
  color: var(--ink);
}
.view-header p {
  margin: 0;
  color: var(--ink-soft);
  max-width: 720px;
  font-size: 14px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.act-card {
  background: var(--paper-raised);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform 0.08s ease;
}
.act-card:hover { border-color: var(--brass); }
.act-card:active { transform: scale(0.99); }

.act-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.act-number {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--red);
  font-weight: 600;
}
.act-title {
  font-size: 14px;
  line-height: 1.4;
  color: var(--ink);
}
.act-meta {
  font-size: 11px;
  color: var(--ink-soft);
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.stamp {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 2px;
  border: 1px solid currentColor;
  white-space: nowrap;
}
.stamp.full { color: var(--ok); }
.stamp.stub {
  color: var(--warn);
  border-style: dashed;
}
.stamp.core { color: var(--red); background: rgba(171,36,29,0.06); }

/* -------------------- reader -------------------- */
.reader {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 26px;
  align-items: start;
}
@media (max-width: 880px) { .reader { grid-template-columns: 1fr; } }

.reader-toc {
  position: sticky;
  top: 0;
  background: var(--paper-raised);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 12px 14px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  font-size: 12.5px;
}
.reader-toc h4 {
  margin: 0 0 8px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--brass);
}
.reader-toc a {
  display: block;
  padding: 3px 0;
  color: var(--ink-soft);
  text-decoration: none;
  border-left: 2px solid transparent;
  padding-left: 8px;
  margin-left: -8px;
}
.reader-toc a:hover { color: var(--ink); border-left-color: var(--brass); }
.reader-toc a.chapter { font-weight: 600; color: var(--ink); margin-top: 6px; }

.reader-doc {
  background: var(--paper-raised);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 30px 38px;
  box-shadow: var(--shadow-card);
}
.reader-doc-header {
  border-bottom: 2px solid var(--ink);
  padding-bottom: 14px;
  margin-bottom: 18px;
}
.reader-doc-header .act-number { font-size: 13px; }
.reader-doc-header h2 {
  font-family: var(--font-display);
  font-size: 22px;
  margin: 6px 0 0;
}
.reader-body {
  font-family: var(--font-body);
  font-size: 14.5px;
  color: #24333f;
  white-space: pre-wrap;
}
.reader-body p { margin: 0 0 12px; }
.reader-body .art-anchor {
  scroll-margin-top: 16px;
}
.reader-body strong.chapter-h {
  display: block;
  font-family: var(--font-display);
  font-size: 17px;
  margin: 26px 0 10px;
  color: var(--red-deep);
}
.reader-body mark {
  background: #f0d9b5;
  padding: 0 2px;
}
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--ink-soft);
  margin-bottom: 14px;
  background: none;
  border: none;
  padding: 0;
}
.back-link:hover { color: var(--ink); }

/* -------------------- profile banner -------------------- */
.profile-banner {
  background: var(--paper-raised);
  border: 1px solid var(--line-soft);
  border-left: 4px solid var(--brass);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 22px;
  font-size: 13.5px;
}
.profile-banner strong { color: var(--ink); }

/* -------------------- proiectare: building types -------------------- */
.tip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}
.tip-card {
  background: var(--paper-raised);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  box-shadow: var(--shadow-card);
}
.tip-card:hover { border-color: var(--brass); }
.tip-card .tip-icon { font-size: 22px; }
.tip-card h3 { font-family: var(--font-display); font-size: 16px; margin: 8px 0 4px; }
.tip-card p { margin: 0; font-size: 12px; color: var(--ink-soft); }

.step-list {
  list-style: none;
  margin: 0; padding: 0;
  counter-reset: step;
}
.step-list li {
  counter-increment: step;
  position: relative;
  padding: 10px 0 10px 40px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13.5px;
}
.step-list li:last-child { border-bottom: none; }
.step-list li::before {
  content: counter(step);
  position: absolute;
  left: 0; top: 8px;
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 1.5px solid var(--red);
  color: var(--red);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 12px;
  display: flex; align-items: center; justify-content: center;
}

.tool-panel {
  background: var(--paper-raised);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-card);
}
.tool-panel h3 { font-family: var(--font-display); margin: 0 0 4px; font-size: 18px; }
.tool-panel .tool-note {
  font-size: 12px; color: var(--ink-soft); margin-bottom: 14px;
}
.tool-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.tool-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.tool-field input, .tool-field select {
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 13px;
  background: #fff;
}
.tool-result {
  background: var(--paper-deep);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 13px;
  display: none;
}
.tool-result.show { display: block; }
.tool-result .due {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px dashed var(--line);
}
.tool-result .due:last-child { border-bottom: none; }
.tool-result .due .lbl { color: var(--ink-soft); }
.tool-result .due .val { font-family: var(--font-mono); font-weight: 600; }
.tool-result .due.overdue .val { color: var(--red); }

.btn-primary {
  background: var(--ink);
  color: #fff;
  border: none;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
}
.btn-primary:hover { background: var(--red-deep); }

/* -------------------- catalog stub list -------------------- */
.catalog-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
}
.catalog-row:last-child { border-bottom: none; }
.catalog-row .catalog-title { color: var(--ink-soft); }

/* -------------------- empty state -------------------- */
.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--ink-soft);
  font-size: 13.5px;
}

/* -------------------- AI chat panel -------------------- */
.ai-panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 520px;
  max-height: calc(100vh - 100px);
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(28,43,57,0.3);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 500;
}
.ai-panel.open { display: flex; }
.ai-panel-head {
  background: var(--ink);
  color: var(--paper-raised);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-display);
  font-size: 15px;
}
.ai-panel-head button {
  background: none; border: none; color: var(--paper-raised);
  font-size: 16px;
}
.ai-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 13px;
}
.ai-msg { max-width: 92%; }
.ai-msg.user { align-self: flex-end; background: var(--ink); color: #fff; padding: 8px 11px; border-radius: 10px 10px 2px 10px; }
.ai-msg.bot { align-self: flex-start; background: var(--paper-deep); padding: 8px 11px; border-radius: 10px 10px 10px 2px; white-space: pre-wrap; }
.ai-msg.bot.loading { color: var(--ink-soft); font-style: italic; }
.ai-sources {
  font-size: 10.5px;
  color: var(--ink-soft);
  margin-top: 6px;
  border-top: 1px dashed var(--line);
  padding-top: 6px;
}
.ai-panel-input {
  border-top: 1px solid var(--line-soft);
  padding: 10px;
  display: flex;
  gap: 8px;
}
.ai-panel-input textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
  font-family: var(--font-body);
  font-size: 13px;
  height: 40px;
}
.ai-panel-input button {
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 0 16px;
  font-weight: 600;
}
.ai-disclaimer {
  font-size: 10px;
  color: var(--ink-soft);
  padding: 6px 12px 10px;
  border-top: 1px solid var(--line-soft);
}

/* -------------------- scrollbars (webkit) -------------------- */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 5px; }
::-webkit-scrollbar-track { background: transparent; }
