:root {
  --primary: #0b1f33;
  --primary-container: #1a3348;
  --secondary: #5a6b7a;
  --tertiary: #0e7c86;
  --tertiary-container: #0a5f67;
  --on-tertiary: #f4fbfc;
  --neutral: #f2f5f8;
  --surface: #ffffff;
  --on-surface: #0b1f33;
  --outline: #c5ced6;
  --error: #b3261e;
  --success: #1b6b4a;
  --warning: #9a6700;
  --font-serif: "Source Serif 4", "Songti SC", "Noto Serif SC", serif;
  --font-sans: "Source Sans 3", "PingFang SC", "Noto Sans SC", sans-serif;
  --radius-sm: 4px;
  --radius-md: 8px;
  --col-0: #0b1f33;
  --wash-0: #ffffff;
  --bg-0: #e6eef2;
  --col-1: #0a5f67;
  --wash-1: #f3fafb;
  --bg-1: #d5eef0;
  --col-2: #6f4b00;
  --wash-2: #fbf8f1;
  --bg-2: #f3e6c4;
  --col-3: #1b6b4a;
  --wash-3: #f3faf6;
  --bg-3: #d7f0e4;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--neutral);
  color: var(--on-surface);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
}

button, input, select, textarea { font: inherit; color: inherit; }

button { cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--tertiary);
  outline-offset: 2px;
}

.app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.top {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 56px;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--outline);
}

.brand { min-width: 0; flex: none; display: flex; align-items: center; gap: 8px; }

.logo { width: 36px; height: 36px; flex: none; }

.top-group { display: flex; flex: none; gap: 8px; }

.top .btn { height: 36px; padding: 0 10px; }

.top select {
  flex: none;
  width: 220px;
  height: 36px;
  border: 1px solid var(--outline);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 0 8px;
}

h1 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.model {
  margin: 0;
  flex: 1;
  min-width: 0;
  color: var(--secondary);
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.actions { display: flex; gap: 8px; flex: none; margin-left: auto; }

.modes { display: flex; flex: none; }

.modes .btn { padding: 0 12px; }

.modes .btn + .btn { margin-left: -1px; }

.modes .btn:first-child { border-radius: 4px 0 0 4px; }

.modes .btn:last-child { border-radius: 0 4px 4px 0; }

.modes .btn[aria-pressed="true"] {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--surface);
  z-index: 1;
}

.btn {
  height: 44px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--outline);
  background: var(--surface);
  color: var(--primary);
  font-size: 0.875rem;
  font-weight: 600;
}

.btn:active { transform: translateY(1px); }

.btn:disabled { opacity: 0.45; cursor: default; transform: none; }

.btn.primary {
  background: var(--tertiary);
  border-color: var(--tertiary);
  color: var(--on-tertiary);
}

.btn.primary:hover:not(:disabled) { background: var(--tertiary-container); }

.hint {
  flex: none;
  margin: 0;
  padding: 8px 32px;
  color: var(--secondary);
  font-size: 0.875rem;
  background: var(--neutral);
}

.board {
  flex: 1;
  min-height: 0;
  display: flex;
  overflow-x: auto;
  background: var(--surface);
}

.split {
  flex: none;
  width: 1px;
  cursor: col-resize;
  background: var(--outline);
  position: relative;
}

.split::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -4px;
  right: -4px;
}

.split.dragging { background: var(--tertiary); }

.col {
  --col: var(--col-0);
  --wash: var(--wash-0);
  --col-bg: var(--bg-0);
  display: flex;
  flex-direction: column;
  min-width: 240px;
  min-height: 0;
}

.col[data-slot="1"] { --col: var(--col-1); --wash: var(--wash-1); --col-bg: var(--bg-1); }
.col[data-slot="2"] { --col: var(--col-2); --wash: var(--wash-2); --col-bg: var(--bg-2); }
.col[data-slot="3"] { --col: var(--col-3); --wash: var(--wash-3); --col-bg: var(--bg-3); }

.col-head, .col-body { background: var(--wash); }

.col-head {
  flex: none;
  padding: 6px 12px;
  border-top: 3px solid var(--col);
  border-bottom: 1px solid var(--outline);
}

.col-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 32px;
}

.col-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  flex: none;
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
}

.swatch {
  width: 10px;
  height: 10px;
  background: var(--col);
  display: inline-block;
  flex: none;
  transform: translateY(1px);
}

.col-sub, .phase {
  margin: 0;
  min-width: 0;
  color: var(--secondary);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.col-sub { flex: none; }

.phase { flex: 1; }

.err {
  margin: 4px 0 0;
  color: var(--error);
  font-size: 0.75rem;
  font-weight: 400;
  min-height: 0;
}

.err:empty { display: none; }

.col-ops { display: flex; flex: none; align-items: center; gap: 2px; margin-left: auto; }

.col-model {
  width: 132px;
  height: 28px;
  border: 1px solid var(--outline);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font: inherit;
  font-size: 0.75rem;
  padding: 0 4px;
}

.text-btn {
  height: 32px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: var(--col);
  font-size: 0.75rem;
  font-weight: 600;
}

.text-btn:hover { text-decoration: underline; }

.col-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 4px 16px 32px;
}

.para {
  position: relative;
  margin: 0 0 1.25em;
  padding: 0;
  border-bottom: 0;
}

.para.changed { box-shadow: inset 3px 0 0 var(--col); }

.para-ops {
  display: none;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  min-height: 32px;
}

.para:has(.para-text.active) {
  background: var(--col-bg);
  box-shadow: inset 0 -2px 0 var(--col);
  padding: 8px 8px 0;
}

.para.changed:has(.para-text.active) { box-shadow: inset 3px 0 0 var(--col), inset 0 -2px 0 var(--col); }

.para:has(.para-text.active) .para-ops { display: flex; }

.tag {
  color: var(--warning);
  font-size: 0.6875rem;
  font-weight: 600;
}

.para-text {
  min-height: 1.6em;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
  outline: none;
}

.para-text:empty::before {
  content: attr(data-placeholder);
  color: var(--secondary);
  font-weight: 400;
}

.para-text:focus { outline: 2px solid var(--tertiary); outline-offset: 2px; }

.para-text.active { background: transparent; box-shadow: none; }

.para-text .mark {
  background: var(--col-bg);
  box-shadow: inset 0 -2px 0 var(--col);
}

.para-text .ink { color: var(--col); font-weight: 600; }

.para-text .eq { color: var(--secondary); }

.para-text del {
  color: var(--error);
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

.para-text del.mark-del {
  color: var(--col);
  background: var(--col-bg);
  font-weight: 400;
}

.para-text del.ink-del {
  color: var(--secondary);
  background: transparent;
  font-weight: 400;
}

.para-text ins {
  color: var(--col);
  background: var(--col-bg);
  text-decoration: none;
  font-weight: 600;
}

.stream {
  margin: 12px 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.6;
}

dialog {
  width: min(760px, calc(100vw - 48px));
  max-height: min(86dvh, 920px);
  padding: 0;
  border: 1px solid var(--outline);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--on-surface);
  box-shadow: 0 12px 40px rgba(11, 31, 51, 0.12);
}

dialog::backdrop { background: rgba(11, 31, 51, 0.45); }

dialog#auth {
  width: min(520px, calc(100vw - 48px));
}

dialog#dlg {
  width: min(1180px, calc(100vw - 32px));
  height: min(94dvh, 960px);
  max-height: 94dvh;
}

#settings-form {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.settings-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 168px 1fr;
}

.settings-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 12px 16px 20px;
  border-right: 1px solid var(--outline);
  overflow: auto;
}

.settings-nav button {
  height: 40px;
  padding: 0 12px 0 16px;
  border: 0;
  background: transparent;
  color: var(--secondary);
  font-size: 0.875rem;
  font-weight: 600;
  text-align: left;
}

.settings-nav button[aria-pressed="true"] {
  color: var(--primary);
  background: var(--neutral);
  box-shadow: inset 3px 0 0 var(--tertiary);
}

#settings-form .dlg-body {
  max-height: none;
  height: 100%;
  padding: 24px 40px 32px 36px;
}

#settings-form .dlg-body > section {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

#settings-form textarea {
  flex: 1;
  min-height: 280px;
}

#settings-form .dlg-actions { justify-content: space-between; }

#settings-form .dlg-actions span:last-child { display: flex; gap: 8px; }

#settings-form .dlg-actions .mail { margin: 0; }

.login-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 28px 32px 24px;
}

.auth-close {
  position: absolute;
  top: 12px;
  right: 12px;
  height: 32px;
  padding: 0 10px;
}

.auth-head { text-align: center; }

.lockup-zh {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.2;
}

.lockup-en {
  margin: 2px 0 12px;
  color: var(--secondary);
  font-size: 0.875rem;
}

.auth-head h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 2rem;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.login-card .field { margin-top: 0; }

.login-card .field input { min-height: 48px; }

.captcha-row { display: flex; gap: 8px; align-items: center; }

.captcha-row input { flex: 1; min-width: 0; }

#captcha-refresh {
  flex: none;
  height: 48px;
  padding: 0;
  border: 1px solid var(--outline);
  border-radius: var(--radius-sm);
  background: var(--neutral);
  line-height: 0;
}

#captcha-refresh img { display: block; height: 46px; width: auto; }

.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.login-card .btn.primary { width: 100%; min-height: 48px; }

.auth-error {
  margin: 0;
  color: var(--error);
  font-size: 0.875rem;
}

.auth-error:empty { display: none; }

.agree {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.875rem;
  line-height: 1.5;
}

.agree input { width: auto; min-height: 0; margin-top: 3px; }

.legal h3 { margin: 16px 0 4px; font-size: 1rem; }

.legal p { margin: 0 0 8px; line-height: 1.7; }

.links { margin: 0; display: flex; justify-content: center; gap: 16px; }

.beian {
  margin: 8px 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--secondary);
  font-size: 0.75rem;
  line-height: 1.5;
}

.beian a { color: inherit; text-decoration: none; }

.beian a:hover { text-decoration: underline; }

.links button {
  border: 0;
  background: transparent;
  color: var(--tertiary);
  font-size: 0.875rem;
  font-weight: 600;
  height: auto;
  padding: 0;
}

.dlg-bar, .dlg-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 32px;
}

.dlg-bar { border-bottom: 1px solid var(--outline); }

.dlg-bar h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 600;
}

.dlg-actions {
  justify-content: flex-end;
  border-top: 1px solid var(--outline);
}

.dlg-body {
  overflow: auto;
  max-height: calc(86dvh - 148px);
  padding: 8px 32px 24px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

.field label, summary {
  font-size: 0.875rem;
  font-weight: 600;
}

.help { margin: 0; color: var(--secondary); font-size: 0.75rem; }

.field input, .field select, .field textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: var(--radius-sm);
  padding: 12px;
  min-height: 44px;
}

.field textarea {
  min-height: 180px;
  resize: vertical;
  line-height: 1.5;
}

.keyline { display: flex; gap: 8px; }

.keyline input { flex: 1; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

details { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--outline); }

summary { cursor: pointer; }

.mail {
  margin: 24px 0 0;
  color: var(--secondary);
  font-size: 0.75rem;
}

.model-row {
  margin-top: 0;
  padding: 10px 0;
  border-top: 1px solid var(--outline);
}

.model-row .row-bar label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 32px;
  font-weight: 600;
}

.model-row input[type="radio"] {
  width: 16px;
  height: 16px;
  min-height: 16px;
  margin: 0;
  padding: 0;
  flex: none;
}

.model-row .name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-row select,
.model-row input[type="text"],
.model-row input[type="password"] {
  width: 100%;
  margin-top: 8px;
  min-height: 44px;
  border: 1px solid var(--outline);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: var(--surface);
}

.model-row .row-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.pick {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--outline);
}

.pick > span { color: var(--secondary); font-size: 0.875rem; font-weight: 600; }

button.col-title {
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  text-align: left;
}

button.col-title:hover { text-decoration: underline; }

.bars { display: flex; flex-direction: column; gap: 8px; }

.bar { display: grid; grid-template-columns: 72px 1fr 40px; align-items: center; gap: 8px; min-height: 32px; }

.bar i {
  display: block;
  height: 12px;
  background: var(--tertiary);
  border-radius: 2px;
}

.bar.miss i { background: var(--secondary); }

.bar b { font-size: 0.875rem; }

.hist { list-style: none; margin: 16px 0 0; padding: 0; }

.hist button {
  width: 100%;
  text-align: left;
  min-height: 44px;
  margin-top: 8px;
  border: 1px solid var(--outline);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 8px 12px;
}

.hist li { padding: 8px 0; border-bottom: 1px solid var(--outline); }

.hist time { display: block; color: var(--secondary); font-size: 0.75rem; }

@media (max-width: 960px) {
  .top { flex-wrap: wrap; padding: 8px 16px; height: auto; }
  .hint, .pick { padding-left: 16px; padding-right: 16px; }
  .grid-2 { grid-template-columns: 1fr; }
  .dlg-bar, .dlg-actions, .dlg-body { padding-left: 16px; padding-right: 16px; }
  .settings-body { grid-template-columns: 1fr; }
  .settings-nav { flex-direction: row; border-right: 0; border-bottom: 1px solid var(--outline); }
  .settings-nav button { flex: none; }
  #settings-form .dlg-actions { flex-wrap: wrap; }
}
