/* chat.ling-lang.org — dark, teal-accented, same color family as ling-lang.org/
   fu.ling-lang.org/ling-lin.me (rainbow palette anchored on --teal), but its
   own layout: a two-pane chat shell instead of a scrolling marketing page.
   No external fonts/JS/CDNs — same rule every site in this ecosystem follows. */

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

:root {
  --red:    #ff1040;
  --teal:   #00e0cc;
  --cyan:   #00c4ff;
  --blue:   #0070ff;
  --violet: #9900ee;

  --bg:       #07070f;
  --bg1:      #0d0d1c;
  --bg2:      #121224;
  --card:     #0f0f1e;
  --text:     #ddddf0;
  --text-dim: #8888ad;
  --white:    #f4f4ff;
  --border:   rgba(255,255,255,0.08);
  --radius:   6px;
  --radius-lg:10px;
  --font-mono: ui-monospace,'JetBrains Mono','Fira Code','Cascadia Code',Consolas,monospace;
  --font-sans: -apple-system,BlinkMacSystemFont,'Segoe UI','Noto Sans',Roboto,sans-serif;
}

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

a { color: var(--teal); text-decoration: none; }
a:hover { color: var(--white); }
a:focus-visible, button:focus-visible, textarea:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
code, pre { font-family: var(--font-mono); }

/* ── app shell: sidebar + main ── */
#app { display: flex; height: 100vh; }

#sidebar {
  width: 272px;
  min-width: 272px;
  background: var(--bg1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 14px;
}

.brand { display: flex; align-items: center; gap: 8px; }
.brand-mark {
  width: 28px; height: 28px; border-radius: var(--radius);
  background: var(--teal); color: #04241f;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.95rem; flex-shrink: 0;
}
.brand-name { font-weight: 700; color: var(--white); font-size: 0.95rem; }
.brand-sub { font-size: 0.7rem; color: var(--text-dim); margin-top: -6px; letter-spacing: 0.02em; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 0.6rem 1rem; border-radius: var(--radius); font-weight: 600;
  font-size: 0.85rem; border: 1px solid transparent; cursor: pointer;
}
.btn-primary { background: var(--teal); color: #04241f; }
.btn-primary:hover { background: #33f0dc; color: #04241f; }
.btn-block { width: 100%; }

#conv-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; margin: 0 -8px; }
.conv-item {
  display: block; padding: 0.55rem 0.7rem; border-radius: var(--radius);
  color: var(--text-dim); font-size: 0.85rem; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.conv-item:hover { background: var(--bg2); color: var(--text); }
.conv-item.on { background: var(--bg2); color: var(--white); border-left: 2px solid var(--teal); }
.conv-empty { padding: 0.7rem; font-size: 0.8rem; color: var(--text-dim); }

#sidebar-footer { font-size: 0.72rem; color: var(--text-dim); border-top: 1px solid var(--border); padding-top: 12px; line-height: 1.8; }
#sidebar-footer a { color: var(--text-dim); }
#sidebar-footer a:hover { color: var(--teal); }

/* ── main pane ── */
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

#thread { flex: 1; overflow-y: auto; padding: 32px 0 12px; }
#thread-empty {
  max-width: 620px; margin: 8vh auto 0; text-align: center; padding: 0 24px;
}
#thread-empty h1 { font-size: 1.9rem; color: var(--white); margin-bottom: 12px; letter-spacing: -0.02em; }
#thread-empty p { color: var(--text-dim); }

.msg { max-width: 760px; margin: 0 auto; padding: 14px 24px; display: flex; flex-direction: column; gap: 4px; }
.msg-role { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-dim); }
.msg-user .msg-role { color: var(--cyan); }
.msg-assistant .msg-role { color: var(--teal); }
.msg-body { white-space: pre-wrap; word-wrap: break-word; color: var(--text); }
.msg-assistant { background: var(--bg1); border-radius: var(--radius-lg); }

/* ── composer ── */
#composer {
  max-width: 760px; width: calc(100% - 48px); margin: 0 auto 20px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  display: flex; align-items: flex-end; gap: 8px; padding: 10px 10px 10px 16px;
}
#composer-input {
  flex: 1; resize: none; background: transparent; border: none; color: var(--text);
  font-family: var(--font-sans); font-size: 0.95rem; line-height: 1.5;
  max-height: 200px; padding: 8px 0;
}
#composer-input::placeholder { color: var(--text-dim); }
#composer-send {
  background: var(--teal); color: #04241f; border: none; border-radius: var(--radius);
  padding: 0.6rem 1.1rem; font-weight: 700; font-size: 0.85rem; cursor: pointer; flex-shrink: 0;
}
#composer-send:disabled { opacity: 0.5; cursor: default; }
#composer-send:hover:not(:disabled) { background: #33f0dc; }

.msg-assistant.pending .msg-body::after {
  content: '\2588'; color: var(--teal); animation: blink 1s steps(1) infinite; margin-left: 2px;
}
@keyframes blink { 50% { opacity: 0; } }

#sidebar-toggle {
  display: none; position: fixed; top: 12px; left: 12px; z-index: 25;
  background: var(--card); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius); width: 36px; height: 36px; cursor: pointer; font-size: 1rem;
}

/* ── mobile ── */
@media (max-width: 720px) {
  #sidebar-toggle { display: block; }
  #sidebar { position: fixed; inset: 0 30% 0 0; z-index: 20; transform: translateX(-100%); transition: transform 0.2s ease; }
  #sidebar.open { transform: translateX(0); }
  #thread-empty { margin-top: 14vh; }
  .msg { padding: 12px 16px; }
  #composer { width: calc(100% - 24px); }
}
