/* ============ STAKHON AI — constructivist propaganda poster ============ */
:root {
  --red: #C8102E;
  --red-dark: #8B0000;
  --red-deep: #6E0F1B;
  --black: #1A1512;
  --ink: #2B231C;
  --paper: #F0E6D2;
  --paper-dark: #E4D6B8;
  --gold: #D4AF37;
  --font-display: 'Oswald', 'Arial Narrow', Impact, sans-serif;
  --font-body: Georgia, 'Times New Roman', serif;
}

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

html, body { height: 100%; }

body {
  display: flex;
  flex-direction: column;
  font-family: var(--font-body);
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    radial-gradient(rgba(43, 35, 28, 0.055) 1px, transparent 1.4px),
    linear-gradient(rgba(200, 16, 46, 0.025), rgba(43, 35, 28, 0.04));
  background-size: 5px 5px, 100% 100%;
}

/* ---------- slogan ticker ---------- */
.ticker {
  background: var(--red);
  color: var(--paper);
  overflow: hidden;
  white-space: nowrap;
  border-bottom: 3px solid var(--black);
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: 0.12em;
  font-size: 0.8rem;
  padding: 4px 0;
}
.ticker-track { display: inline-block; animation: ticker 55s linear infinite; }
.ticker-track span { margin-right: 3.5em; }
.ticker-track .t-star { color: var(--gold); }
@keyframes ticker { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* ---------- masthead ---------- */
.masthead {
  background: var(--black);
  color: var(--paper);
  border-bottom: 6px solid var(--red);
  position: relative;
  overflow: hidden;
}
.masthead::after { /* diagonal red ray, constructivist style */
  content: '';
  position: absolute;
  top: -60%;
  right: -6%;
  width: 42%;
  height: 260%;
  background: linear-gradient(90deg, rgba(200,16,46,0.28), rgba(200,16,46,0.08));
  transform: rotate(18deg);
  pointer-events: none;
}
.masthead-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.star { width: 52px; height: 52px; fill: var(--red); filter: drop-shadow(0 0 6px rgba(200,16,46,0.6)); flex-shrink: 0; }
.masthead-titles { flex: 1; min-width: 0; }
.masthead h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.5rem, 4.5vw, 2.4rem);
  letter-spacing: 0.06em;
  line-height: 1;
  text-transform: uppercase;
}
.masthead h1 .latin { color: var(--red); }
.tagline {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(0.62rem, 1.8vw, 0.8rem);
  letter-spacing: 0.22em;
  color: var(--gold);
  margin-top: 4px;
}
.admin-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--paper);
  opacity: 0.55;
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 0.6rem;
  letter-spacing: 0.2em;
  transition: opacity 0.2s;
  flex-shrink: 0;
}
.admin-link:hover { opacity: 1; }
.admin-link svg { width: 20px; height: 20px; fill: var(--gold); }

/* ---------- controls ---------- */
.controls {
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 10px 18px 0;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.control-label {
  font-family: var(--font-display);
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  color: var(--red-deep);
}
select, .btn-ghost {
  font-family: var(--font-display);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  background: var(--paper);
  color: var(--ink);
  border: 2px solid var(--black);
  padding: 6px 10px;
  box-shadow: 3px 3px 0 var(--red);
  cursor: pointer;
}
select:focus, .btn-ghost:focus { outline: 2px solid var(--red); }
.btn-ghost { margin-left: auto; text-transform: uppercase; }
.btn-ghost:hover { background: var(--red); color: var(--paper); }

/* ---------- chat ---------- */
.chat {
  flex: 1;
  overflow-y: auto;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.msg { max-width: 85%; position: relative; }
.msg-assistant { align-self: flex-start; }
.msg-user { align-self: flex-end; }

.msg-inner {
  padding: 12px 16px;
  line-height: 1.55;
  font-size: 0.95rem;
  overflow-wrap: break-word;
}
.msg-assistant .msg-inner {
  background: #FAF3E3;
  border: 1.5px solid rgba(43,35,28,0.35);
  border-left: 6px solid var(--red);
  box-shadow: 4px 4px 0 rgba(43,35,28,0.15);
}
.msg-user .msg-inner {
  background: var(--red-deep);
  color: var(--paper);
  border: 1.5px solid var(--black);
  border-right: 6px solid var(--gold);
  box-shadow: -4px 4px 0 rgba(43,35,28,0.2);
  white-space: pre-wrap;
}
.msg-tag {
  font-family: var(--font-display);
  font-size: 0.58rem;
  font-weight: 500;
  letter-spacing: 0.24em;
  margin-bottom: 3px;
  text-transform: uppercase;
}
.msg-assistant .msg-tag { color: var(--red); }
.msg-user .msg-tag { color: var(--red-deep); text-align: right; }

.msg-error .msg-inner {
  background: var(--black);
  color: #F5B7B1;
  border-left: 6px solid var(--gold);
  font-family: var(--font-display);
  letter-spacing: 0.04em;
}

.msg img.gen { max-width: 100%; display: block; border: 3px solid var(--black); box-shadow: 5px 5px 0 var(--red); margin-top: 8px; }

.cursor-blink::after { content: '▌'; color: var(--red); animation: blink 0.9s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* markdown inside assistant messages */
.msg-inner h1, .msg-inner h2, .msg-inner h3 {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--red-deep);
  margin: 0.7em 0 0.35em;
  line-height: 1.15;
}
.msg-inner h1 { font-size: 1.25em; border-bottom: 2px solid var(--red); padding-bottom: 2px; }
.msg-inner h2 { font-size: 1.12em; }
.msg-inner h3 { font-size: 1.02em; }
.msg-inner p { margin: 0.5em 0; }
.msg-inner p:first-child { margin-top: 0; }
.msg-inner p:last-child { margin-bottom: 0; }
.msg-inner ul, .msg-inner ol { margin: 0.5em 0 0.5em 1.4em; }
.msg-inner li { margin: 0.2em 0; }
.msg-inner blockquote {
  border-left: 4px solid var(--gold);
  padding-left: 10px;
  margin: 0.5em 0;
  color: rgba(43,35,28,0.75);
  font-style: italic;
}
.msg-inner a { color: var(--red); font-weight: bold; }
.msg-inner code {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
  font-size: 0.86em;
  background: rgba(43,35,28,0.09);
  border: 1px solid rgba(43,35,28,0.18);
  padding: 1px 5px;
}
.msg-inner pre {
  background: var(--black);
  color: #EDE3CB;
  padding: 12px 14px;
  overflow-x: auto;
  margin: 0.6em 0;
  border-left: 5px solid var(--gold);
  box-shadow: 3px 3px 0 rgba(43,35,28,0.25);
}
.msg-inner pre code { background: none; border: none; padding: 0; font-size: 0.83rem; line-height: 1.5; }
.msg-inner hr { border: none; border-top: 2px dashed var(--red); margin: 0.8em 0; }
.msg-inner table { border-collapse: collapse; margin: 0.6em 0; max-width: 100%; display: block; overflow-x: auto; }
.msg-inner th, .msg-inner td { border: 1.5px solid var(--ink); padding: 4px 10px; font-size: 0.88em; }
.msg-inner th { background: var(--red-deep); color: var(--paper); font-family: var(--font-display); letter-spacing: 0.05em; }

/* ---------- composer ---------- */
.composer {
  background: var(--black);
  border-top: 6px solid var(--red);
  padding: 12px 18px;
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.composer textarea {
  flex: 1;
  max-width: 780px;
  margin-left: auto;
  resize: none;
  font-family: var(--font-body);
  font-size: 0.95rem;
  line-height: 1.45;
  background: var(--paper);
  color: var(--ink);
  border: 2px solid var(--gold);
  padding: 10px 12px;
  min-height: 44px;
  max-height: 180px;
}
.composer textarea:focus { outline: 2px solid var(--red); }
.composer button {
  margin-right: auto;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.14em;
  background: var(--red);
  color: var(--paper);
  border: 2px solid var(--gold);
  padding: 10px 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: transform 0.08s, background 0.2s;
}
.composer button:hover:not(:disabled) { background: var(--red-dark); }
.composer button:active:not(:disabled) { transform: translate(1px, 1px); }
.composer button:disabled { opacity: 0.5; cursor: wait; }
.send-star { font-size: 1.1rem; }

@media (min-width: 940px) {
  .composer { justify-content: center; }
  .composer textarea { margin-left: 0; }
  .composer button { margin-right: 0; }
}

/* ---------- footer ---------- */
.footer {
  background: var(--black);
  color: rgba(240,230,210,0.5);
  font-family: var(--font-display);
  font-size: 0.58rem;
  letter-spacing: 0.22em;
  text-align: center;
  padding: 6px 10px 8px;
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}
.footer-sep { color: var(--red); }

/* ---------- scrollbar ---------- */
.chat::-webkit-scrollbar { width: 10px; }
.chat::-webkit-scrollbar-track { background: var(--paper-dark); }
.chat::-webkit-scrollbar-thumb { background: var(--red); border: 2px solid var(--paper-dark); }

@media (max-width: 600px) {
  .msg { max-width: 94%; }
  .btn-ghost { margin-left: 0; }
}
