:root {
  --ink: #182332;
  --muted: #71808b;
  --paper: #f5f4ef;
  --panel: #fffef9;
  --line: #d8d9d2;
  --q: #a9dcdb;
  --a: #f2cf65;
  --accent: #ef6c4d;
  font-family: Inter, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
html, body { min-width: 320px; min-height: 100%; margin: 0; background: var(--paper); }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.is-hidden { display: none !important; }

.app-shell { min-height: 100vh; }
.topbar { height: 64px; padding: 0 clamp(22px, 5vw, 76px); display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.wordmark { color: var(--ink); text-decoration: none; font-size: 1rem; font-weight: 800; letter-spacing: -.045em; }
.member-tools { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: .78rem; }
.member-tools button, .text-button { padding: 0; border: 0; border-bottom: 1px solid currentColor; color: var(--ink); background: transparent; font-size: .76rem; line-height: 1.4; }

.auth-view { min-height: calc(100vh - 64px); display: grid; place-items: center; padding: 28px; }
.auth-card { width: min(100%, 350px); display: grid; gap: 15px; padding: 30px; background: var(--panel); border: 1px solid var(--ink); box-shadow: 8px 8px 0 var(--q); }
.auth-card h1 { margin: 0 0 10px; font-size: 1.4rem; letter-spacing: -.05em; }
.auth-card label { display: grid; gap: 6px; font-size: .75rem; }
.auth-card input { width: 100%; border: 1px solid var(--line); border-radius: 0; background: transparent; padding: 10px 11px; color: var(--ink); outline: none; }
.auth-card input:focus { border-color: var(--ink); box-shadow: 3px 3px 0 var(--q); }
.primary-button { min-height: 39px; border: 1px solid var(--ink); border-radius: 0; background: var(--ink); color: #fff; padding: 0 16px; font-weight: 700; font-size: .78rem; transition: background 140ms ease, transform 140ms ease; }
.primary-button:hover:not(:disabled) { background: var(--accent); transform: translateY(-1px); }
.primary-button:disabled { cursor: not-allowed; opacity: .45; }
.auth-card .text-button { justify-self: start; color: var(--muted); }
.form-error { min-height: 1rem; margin: 0; color: var(--accent); font-size: .72rem; line-height: 1.45; }

.entry-view { min-height: calc(100vh - 64px); display: grid; place-items: center; padding: 28px; }
.entry-grid { display: grid; grid-template-columns: repeat(2, minmax(190px, 270px)); gap: 18px; }
.entry-button { min-height: 230px; border: 1px solid var(--ink); color: var(--ink); font-size: clamp(1.6rem, 3vw, 2.4rem); font-weight: 800; letter-spacing: -.07em; transition: transform 150ms ease, box-shadow 150ms ease; }
.entry-button:hover { transform: translateY(-5px); box-shadow: 7px 8px 0 var(--ink); }
.entry-q { background: var(--q); }
.entry-a { background: var(--a); }

.conversation { min-height: calc(100vh - 64px); display: grid; grid-template-columns: 145px minmax(0, 1fr); }
.conversation-rail { padding: 27px 22px; border-right: 1px solid var(--line); display: flex; flex-direction: column; align-items: flex-start; gap: 22px; }
.role-indicator { font-size: 1.15rem; font-weight: 800; letter-spacing: -.055em; }
.conversation-main { min-width: 0; display: grid; grid-template-rows: 67px minmax(280px, 1fr) auto; }
.conversation-header { padding: 0 clamp(22px, 5vw, 70px); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; font-size: .84rem; }
.conversation-header > span:first-child { font-weight: 800; }
#connectionStatus { color: var(--muted); font-size: .72rem; }
.timeline { min-height: 360px; max-height: calc(100vh - 331px); overflow-y: auto; padding: 28px clamp(22px, 5vw, 70px); }
.message { width: min(100%, 720px); margin-bottom: 21px; display: grid; gap: 7px; }
.message-a { margin-left: auto; }
.message-meta { color: var(--muted); font-size: .68rem; }
.message-a .message-meta { text-align: right; }
.message-bubble { padding: 14px 16px; background: var(--panel); border: 1px solid var(--line); }
.message-q .message-bubble { border-left: 3px solid var(--q); }
.message-a .message-bubble { border-right: 3px solid var(--a); }
.original-text, .translated-text { margin: 0; white-space: pre-wrap; line-height: 1.6; }
.original-text { font-size: .92rem; }
.translated-text { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); color: var(--muted); font-size: .83rem; }
.file-card { margin-top: 12px; padding: 11px; display: flex; align-items: center; gap: 10px; border: 1px dashed var(--muted); color: var(--ink); text-decoration: none; }
.file-icon { display: grid; place-items: center; width: 34px; height: 34px; flex: 0 0 34px; background: var(--q); border-radius: 50%; font-size: .62rem; font-weight: 800; }
.file-info { min-width: 0; display: grid; gap: 3px; }
.file-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .78rem; }
.file-info small { color: var(--muted); font-size: .67rem; }

.composer { padding: 17px clamp(22px, 5vw, 70px) 22px; border-top: 1px solid var(--line); background: rgba(255, 254, 249, .45); }
.input-wrap { display: block; position: relative; border: 1px solid var(--ink); background: var(--panel); }
.input-wrap:focus-within { box-shadow: 4px 4px 0 var(--q); }
textarea { display: block; width: 100%; min-height: 76px; max-height: 180px; resize: vertical; border: 0; outline: 0; padding: 12px 50px 28px 13px; color: var(--ink); background: transparent; line-height: 1.55; }
.char-count { position: absolute; right: 11px; bottom: 9px; color: var(--muted); font-size: .65rem; }
.translation-preview { min-height: 45px; margin-top: 9px; padding: 9px 12px; border-left: 3px solid var(--q); background: #eaf5f3; }
.translation-preview.is-empty { opacity: .48; background: transparent; border-left-color: var(--line); }
.translation-preview span { color: var(--muted); font-size: .66rem; }
.translation-preview p { margin: 5px 0 0; white-space: pre-wrap; color: var(--ink); font-size: .82rem; line-height: 1.5; }
.composer-actions { margin-top: 12px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.upload-trigger { display: inline-flex; align-items: center; color: var(--ink); border-bottom: 1px solid currentColor; font-size: .75rem; cursor: pointer; }
.upload-trigger input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }
.file-picked { max-width: 260px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--muted); font-size: .7rem; }
.send-button { margin-left: auto; }
.file-note { margin: 9px 0 0; color: var(--muted); font-size: .63rem; }
.toast { position: fixed; left: 50%; bottom: 24px; max-width: min(420px, calc(100% - 32px)); padding: 10px 14px; color: #fff; background: var(--ink); font-size: .76rem; opacity: 0; pointer-events: none; transform: translate(-50%, 16px); transition: opacity 160ms ease, transform 160ms ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 650px) {
  .topbar { padding: 0 20px; }
  .entry-grid { width: 100%; grid-template-columns: 1fr; }
  .entry-button { min-height: 150px; }
  .conversation { display: block; }
  .conversation-rail { padding: 14px 20px; border-right: 0; border-bottom: 1px solid var(--line); flex-direction: row; align-items: center; justify-content: space-between; }
  .conversation-main { min-height: calc(100vh - 122px); grid-template-rows: 52px minmax(300px, 1fr) auto; }
  .conversation-header { padding: 0 20px; }
  .timeline { max-height: none; padding: 22px 20px; }
  .composer { padding: 15px 20px 20px; }
  .send-button { width: 100%; margin-left: 0; }
}
