/* ------------------------------------------------------------
   LANGMAN WEB UI — Tactile Craft & Paper Aesthetic
------------------------------------------------------------ */

@font-face {
  font-family: "Rock Star";
  src: url("assets/fonts/RockStar.woff2") format("woff2"),
       url("assets/fonts/RockStar.ttf")  format("truetype");
  font-display: swap;
}

:root {
  --paper:        #d4d7cb;
  --paper-raised: #e4e7dc;
  --paper-card:   #f7f9f2;
  --ink:          #222420;
  --ink-soft:     #52564c;
  --ink-muted:    #7b8074;
  --olive:        #374320;
  --olive-light:  #4d5d2c;
  --olive-bright: #687c3c;
  --cream:        #fafcf5;
  --danger:       #933526;
  --shadow-ink:   rgba(34, 36, 32, 0.9);

  --display: "Rock Star", "Staatliches", sans-serif;
  --casual:  "Staatliches", sans-serif;
  --body:    "Archivo Narrow", sans-serif;

  --wobble-btn: 255px 15px 225px 15px / 15px 225px 15px 255px;
  --wobble-card: 18px 8px 16px 10px / 10px 16px 8px 18px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  background-color: var(--paper);
  background-image: 
    radial-gradient(var(--ink-muted) 0.75px, transparent 0.75px);
  background-size: 24px 24px;
  background-position: 0 0;
  color: var(--ink);
  font-family: var(--body);
  font-size: 19px;
  letter-spacing: 0.2px;
}

::selection { background: var(--olive); color: var(--cream); }

/* ---------- Top Bar ---------- */
.topbar {
  display: flex; 
  align-items: center; 
  justify-content: space-between;
  gap: 16px; 
  padding: 14px 24px;
  background: var(--paper-raised);
  border-bottom: 3px solid var(--ink);
  box-shadow: 0 4px 0 rgba(0,0,0,0.05);
}

.brand { 
  height: 42px; 
  transition: transform 0.2s ease;
}
.brand:hover {
  transform: scale(1.02) rotate(-1deg);
}

.pill {
  display: inline-flex; 
  align-items: center; 
  gap: 8px;
  padding: 5px 14px;
  border: 2px solid var(--ink);
  border-radius: var(--wobble-btn);
  background: var(--paper-card);
  font-family: var(--casual); 
  font-size: 0.95rem;
  letter-spacing: 0.75px;
  box-shadow: 2px 2px 0 var(--ink);
}

.pill .dot { 
  width: 10px; 
  height: 10px; 
  border-radius: 50%; 
  background: var(--ink-soft); 
  position: relative;
}

.pill.online .dot { 
  background: var(--olive-bright); 
}
.pill.online .dot::after {
  content: "";
  position: absolute;
  top: -3px; left: -3px; right: -3px; bottom: -3px;
  border-radius: 50%;
  border: 2px solid var(--olive-bright);
  animation: pulse 1.8s infinite ease-out;
}

.pill.offline .dot { background: var(--danger); }

@keyframes pulse {
  0% { transform: scale(0.8); opacity: 0.9; }
  100% { transform: scale(1.8); opacity: 0; }
}

/* ---------- Layout ---------- */
.shell {
  flex: 1; 
  min-height: 0;
  width: min(880px, 100%);
  margin: 0 auto; 
  padding: 0 20px;
  display: flex; 
  flex-direction: column;
}

.toolbar { 
  display: flex; 
  align-items: center; 
  gap: 14px; 
  padding: 16px 4px 8px; 
}

.picker { 
  display: inline-flex; 
  align-items: center; 
  gap: 10px; 
}
.picker-label { 
  font-family: var(--casual); 
  font-size: 1.1rem;
  letter-spacing: 1px; 
}

select {
  font-family: var(--casual); 
  font-size: 1.05rem; 
  letter-spacing: .5px;
  padding: 6px 14px;
  border: 2px solid var(--ink); 
  border-radius: var(--wobble-btn);
  background: var(--paper-card); 
  color: var(--ink); 
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--ink);
  outline: none;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
select:hover {
  transform: translateY(-1px);
  box-shadow: 3px 3px 0 var(--ink);
}

.meta { 
  font-style: italic; 
  color: var(--ink-soft); 
  font-size: 0.95rem;
}
#new-chat { margin-left: auto; }

/* ---------- Chat Area ---------- */
.chat { 
  flex: 1; 
  min-height: 0; 
  overflow-y: auto; 
  padding: 12px 8px 16px; 
}

.chat::-webkit-scrollbar { width: 8px; }
.chat::-webkit-scrollbar-track { background: transparent; }
.chat::-webkit-scrollbar-thumb { 
  background: var(--ink-muted); 
  border-radius: 6px; 
  border: 2px solid var(--paper); 
}
.chat::-webkit-scrollbar-thumb:hover { background: var(--olive); }

.msg { 
  display: flex; 
  gap: 12px; 
  align-items: flex-end; 
  margin: 18px 0; 
  animation: msgIn 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.msg.user { justify-content: flex-end; }
.avatar { 
  width: 38px; 
  height: 38px; 
  flex: none; 
  filter: drop-shadow(2px 2px 0 var(--ink));
  transform: rotate(-6deg); 
  transition: transform 0.2s ease;
}
.avatar:hover { transform: rotate(0deg) scale(1.1); }

.bubble {
  max-width: min(78%, 62ch);
  padding: 12px 18px;
  border: 2.5 solid var(--ink);
  border-radius: var(--wobble-card);
  background: var(--cream);
  color: var(--ink);
  box-shadow: 4px 4px 0 var(--shadow-ink);
  white-space: pre-wrap; 
  line-height: 1.5;
  transform: rotate(-.25deg);
  position: relative;
}

.msg.user .bubble {
  background: var(--olive); 
  border-color: var(--ink); 
  color: var(--cream);
  transform: rotate(.25deg);
  box-shadow: -4px 4px 0 var(--shadow-ink);
}

.bubble.typing::after {
  content: " ✦  ✦  ✦"; 
  color: var(--olive); 
  font-weight: bold;
  animation: blink 1.2s infinite ease-in-out;
}
@keyframes blink { 0%, 100% { opacity: 0.2; } 50% { opacity: 1; } }

/* ---------- Empty State ---------- */
.empty { 
  text-align: center; 
  padding: 6vh 12px 0; 
  display: flex;
  flex-direction: column;
  align-items: center;
}
.empty-star { 
  width: 110px; 
  filter: drop-shadow(3px 3px 0 var(--ink));
  transform: rotate(-8deg); 
  animation: float 4s ease-in-out infinite; 
}
@keyframes float { 
  0%, 100% { transform: rotate(-8deg) translateY(0px); } 
  50% { transform: rotate(-3deg) translateY(-10px); } 
}

.empty h1 {
  font-family: var(--display);
  font-size: clamp(2.4rem, 6vw, 3.8rem);
  letter-spacing: 2px; 
  margin: 14px 0 6px;
  text-shadow: 2px 2px 0 var(--paper-raised);
}

.chips { 
  display: flex; 
  flex-wrap: wrap; 
  gap: 12px; 
  justify-content: center; 
  margin-top: 20px;
  max-width: 650px;
}
.chip {
  font-family: var(--body); 
  font-weight: 600; 
  font-size: 0.98rem;
  padding: 10px 18px; 
  background: var(--paper-card);
  border: 2px dashed var(--ink); 
  border-radius: 999px; 
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--ink);
  transition: all 0.15s ease;
}
.chip:hover { 
  background: var(--olive); 
  color: var(--cream);
  border-style: solid;
  transform: translateY(-2deg) rotate(-1deg); 
  box-shadow: 4px 4px 0 var(--ink);
}
.chip:active {
  transform: translateY(1px);
  box-shadow: 1px 1px 0 var(--ink);
}

/* ---------- Composer ---------- */
.composer { 
  display: flex; 
  gap: 12px; 
  align-items: flex-end; 
  padding: 14px 0 10px; 
}
.composer textarea {
  flex: 1; 
  resize: none; 
  font: inherit; 
  line-height: 1.45;
  padding: 12px 18px; 
  max-height: 160px; 
  outline: none;
  border: 2.5px solid var(--ink);
  border-radius: 14px 6px 16px 8px / 8px 16px 6px 14px;
  background: var(--cream); 
  color: var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.composer textarea:focus { 
  border-color: var(--olive-bright); 
  box-shadow: 4px 4px 0 var(--olive); 
}

/* ---------- Buttons ---------- */
.btn {
  font-family: var(--casual); 
  font-size: 1.1rem; 
  letter-spacing: 1px;
  padding: 10px 22px; 
  cursor: pointer;
  border: 2.5px solid var(--ink); 
  border-radius: var(--wobble-btn);
  background: var(--paper-card); 
  color: var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  transition: transform 0.1s ease, box-shadow 0.1s ease, background-color 0.15s ease;
}
.btn:hover  { 
  transform: translateY(-2deg) rotate(-1deg); 
  box-shadow: 5px 5px 0 var(--ink);
}
.btn:active { 
  transform: translateY(2deg); 
  box-shadow: 1px 1px 0 var(--ink);
}
.btn.solid  { 
  background: var(--olive); 
  border-color: var(--ink); 
  color: var(--cream); 
  min-width: 100px; 
}
.btn.solid:hover { background: var(--olive-light); }
.btn.solid.stop { 
  background: var(--danger); 
  border-color: var(--ink); 
}
.btn.ghost { 
  background: transparent; 
  box-shadow: none;
  border-style: dashed;
}
.btn.ghost:hover {
  background: var(--paper-card);
  border-style: solid;
  box-shadow: 3px 3px 0 var(--ink);
}

.foot { 
  text-align: center; 
  padding: 10px 0 14px; 
  color: var(--ink-soft); 
  font-size: 0.9rem; 
  font-style: italic; 
}

@media (max-width: 600px) {
  .topbar { padding: 10px 16px; }
  .brand { height: 32px; }
  .meta { display: none; }
  .bubble { max-width: 88%; }
  .btn { padding: 8px 16px; }
}