:root {
  --bg: #fbf7f0;
  --card: #fffdf8;
  --ink: #2c2419;
  --muted: #857a68;
  --line: #e8ddca;
  --brand: #b4451f;
  --brand-soft: #fbeee4;
  --ok: #2f7a4e;
  --warn: #b4451f;
  --radius: 14px;
  --shadow: 0 6px 18px rgba(120, 90, 40, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16130f;
    --card: #211c17;
    --ink: #f2e9dc;
    --muted: #a99b86;
    --line: #332b22;
    --brand: #ef9a6a;
    --brand-soft: #2d231b;
    --ok: #7ddc9f;
    --warn: #f0a37c;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, 'Songti SC', 'PingFang SC', 'Microsoft YaHei', serif;
  font-size: 15px;
  line-height: 1.65;
  -webkit-text-size-adjust: 100%;
}

body { overflow-x: hidden; }

.app {
  max-width: 680px;
  margin: 0 auto;
  padding: 16px 14px 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.head h1 { font-size: 20px; margin: 0; letter-spacing: 1px; }
.head .tag { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}

.next { display: flex; align-items: center; gap: 12px; }
.next .label { font-size: 13px; color: var(--muted); }
.next .char {
  font-size: 28px;
  font-weight: 700;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: 12px;
  min-width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
}
.next .char.small { font-size: 14px; font-weight: 600; color: var(--muted); background: transparent; padding: 0; }
.next .meta { margin-left: auto; font-size: 12px; color: var(--muted); text-align: right; }

.lines {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 46vh;
  overflow-y: auto;
}
.lines li {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
}
.lines li .text { font-size: 17px; letter-spacing: 1px; font-weight: 600; word-break: break-all; }
.lines li .who { font-size: 12px; color: var(--muted); margin-left: auto; white-space: nowrap; }
.lines li .idx { font-size: 11px; color: var(--muted); min-width: 20px; }
.lines li.me { background: var(--brand-soft); border-color: transparent; }

.empty { color: var(--muted); font-size: 14px; text-align: center; padding: 18px 6px; }

.form { display: flex; gap: 8px; }
input[type='text'] {
  flex: 1;
  min-width: 0;
  font-size: 16px;
  font-family: inherit;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  min-height: 44px;
}
input[type='text']:focus { outline: 2px solid var(--brand); outline-offset: 1px; }

button {
  font-size: 15px;
  font-family: inherit;
  padding: 10px 16px;
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
}
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
button:disabled { opacity: 0.55; cursor: not-allowed; }

.row { display: flex; gap: 8px; flex-wrap: wrap; }

.msg { font-size: 14px; min-height: 22px; }
.msg.err { color: var(--warn); }
.msg.ok { color: var(--ok); }

.rules { font-size: 13px; color: var(--muted); }
.rules b { color: var(--ink); font-weight: 600; }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--brand-soft);
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 13px;
}

.foot { font-size: 12px; color: var(--muted); text-align: center; }

@media (max-width: 380px) {
  .app { padding: 12px 10px 22px; }
  .next .char { font-size: 24px; min-width: 48px; height: 48px; }
}
