:root {
  --bg: #101418;
  --panel: #181e24;
  --border: #263039;
  --text: #e8edf2;
  --muted: #8b98a5;
  --accent: #38bdf8;
  --accent-dark: #0ea5e9;
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "Noto Sans TC", sans-serif;
  min-height: 100vh;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.brand { font-weight: 700; letter-spacing: 0.5px; }

.chip {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
}

.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.dot.green { background: var(--ok); }
.dot.yellow { background: var(--warn); }
.dot.red { background: var(--err); }

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

h1 { font-size: 22px; margin: 8px 0 4px; }
h2 { font-size: 16px; margin: 0 0 6px; }
.sub { color: var(--muted); line-height: 1.6; margin-top: 0; }

.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
@media (max-width: 560px) { .cards { grid-template-columns: 1fr; } }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
}
.card p { color: var(--muted); font-size: 13px; line-height: 1.5; margin-top: 0; }
.card button { width: 100%; margin-top: 10px; }

input#codeInput {
  width: 100%;
  margin-top: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 22px;
  letter-spacing: 8px;
  text-align: center;
  padding: 10px 0 10px 8px;
  outline: none;
}
input#codeInput:focus { border-color: var(--accent); }

button {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 15px;
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary { background: var(--accent-dark); border-color: transparent; font-weight: 600; }
button.primary:hover:not(:disabled) { filter: brightness(1.1); }
button.ghost { background: transparent; color: var(--muted); }

.hint { color: var(--muted); font-size: 13px; line-height: 1.5; }

.bigcode {
  font-family: ui-monospace, Consolas, monospace;
  font-size: clamp(44px, 12vw, 64px);
  letter-spacing: 0.35em;
  text-align: center;
  margin: 18px 0 6px;
  color: var(--accent);
  user-select: all;
}

.statusline { text-align: center; color: var(--muted); }
.row { display: flex; gap: 10px; justify-content: center; margin-top: 16px; }

.qrbox { text-align: center; margin-top: 22px; }
.qrbox img { background: #fff; border-radius: 10px; padding: 8px; }

#feed { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }

.bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  white-space: pre-wrap;
  word-break: break-word;
  align-self: flex-start;
}
.bubble.mine { align-self: flex-end; background: #14304a; border-color: #1d4468; }
.bubble .ts { display: block; font-size: 11px; color: var(--muted); margin-top: 4px; }

.fcard {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
}
.fcard.mine { border-color: #1d4468; }
.fcard .fname { font-weight: 600; word-break: break-all; }
.fcard .fmeta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.fcard .fstatus { font-size: 13px; margin-top: 6px; color: var(--muted); }
.fcard.done .fstatus { color: var(--ok); }
.fcard.cancelled .fstatus { color: var(--err); }

.bar { height: 8px; background: var(--bg); border-radius: 999px; overflow: hidden; margin-top: 8px; border: 1px solid var(--border); }
.bar > i { display: block; height: 100%; width: 0%; background: var(--accent); transition: width 0.15s linear; }

.composer { display: flex; gap: 8px; align-items: stretch; }
.composer textarea {
  flex: 1;
  resize: vertical;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
}
.composer textarea:focus { border-color: var(--accent); }

.dropzone {
  margin-top: 14px;
  border: 2px dashed var(--border);
  border-radius: 14px;
  padding: 18px;
  text-align: center;
  color: var(--muted);
}
.dropzone.over { border-color: var(--accent); color: var(--text); }
.dropzone p { margin: 0 0 10px; }

#btnLeave { margin-top: 18px; width: 100%; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: #222c36;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 14px;
  max-width: 90vw;
  z-index: 99;
}

.vh {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.hidden { display: none !important; }
