:root {
  --bg: #f4f0ea;
  --panel: #fffaf2;
  --ink: #262521;
  --muted: #6f6a60;
  --accent: #e07b2a;
  --accent-dark: #c76314;
  --border: #e6ded2;
  --chat-c: #fff1cf;
  --chat-s: #e7f0ff;
  --shadow: 0 16px 30px rgba(34, 26, 18, 0.12);
  --shadow-soft: 0 8px 16px rgba(34, 26, 18, 0.08);
  --topbar-height: 68px;
  --left-width: 280px;
  --right-width: 360px;
  font-family: "Noto Serif SC", "STSong", "Songti SC", "Source Han Serif SC",
    "PingFang SC", serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at top left, #fff4e4 0%, #f4f0ea 45%, #efe7db 100%);
  color: var(--ink);
  height: 100vh;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-height);
  padding: 0 28px;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(90deg, #fff7ea 0%, #fdf4e3 45%, #f6efe4 100%);
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 13px;
  letter-spacing: 0.08em;
}

.brand-title {
  font-size: 18px;
  letter-spacing: 0.08em;
}

.mode-tabs {
  display: flex;
  align-items: center;
  gap: 18px;
}

.mode-tab {
  position: relative;
  color: var(--muted);
  padding: 6px 2px 10px;
  border-radius: 6px;
  font-size: 15px;
  cursor: pointer;
  transition: color 0.2s ease;
  letter-spacing: 0.06em;
}

.mode-tab::after {
  content: "";
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 2px;
  height: 2px;
  border-radius: 999px;
  background: transparent;
  box-shadow: none;
}

.mode-tab:hover {
  color: var(--ink);
}

.mode-tab.active {
  color: var(--ink);
  font-weight: 600;
}

.mode-tab.active::after {
  background: var(--accent);
  box-shadow: 0 0 10px rgba(224, 123, 42, 0.5);
}

.user-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-info {
  font-size: 13px;
  color: var(--muted);
}

.user-menu {
  position: relative;
}

.user-menu.is-empty {
  visibility: hidden;
}

.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: 1px solid transparent;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.user-menu-trigger:hover,
.user-menu-trigger[aria-expanded="true"] {
  background: #fff1dc;
  border-color: var(--border);
  box-shadow: var(--shadow-soft);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #f3e3cf;
  color: var(--ink);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.user-meta-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.user-name {
  font-size: 13px;
  color: var(--ink);
  line-height: 1;
}

.user-role {
  font-size: 11px;
  color: var(--muted);
  line-height: 1;
}

.user-chevron {
  font-size: 11px;
  color: var(--muted);
}

.user-menu-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  display: none;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  min-width: 160px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-soft);
  z-index: 80;
}

.user-menu-dropdown.open {
  display: flex;
}

.menu-item {
  background: transparent;
  border: 1px solid transparent;
  text-align: left;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--ink);
  transition: background 0.2s ease, border-color 0.2s ease;
}

.menu-item:hover {
  background: #fff1dc;
  border-color: #f0d7ba;
}

.menu-item:focus {
  outline: none;
  border-color: var(--accent);
}

.app {
  display: grid;
  grid-template-columns: var(--left-width) 10px minmax(420px, 1fr) 10px var(--right-width);
  gap: 20px;
  padding: 22px 24px 24px;
  flex: 1;
  min-height: 0;
  height: calc(100vh - var(--topbar-height));
  overflow: hidden;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.splitter {
  width: 10px;
  cursor: col-resize;
  position: relative;
}

.splitter::before {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 2px;
  height: 60%;
  background: #d9cbb5;
  border-radius: 2px;
}

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

.panel-header h1 {
  font-size: 18px;
  margin: 0;
  letter-spacing: 0.04em;
}

.hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.btn {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.18s ease;
  box-shadow: var(--shadow-soft);
}

.btn:hover:enabled {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover:enabled {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.task-list {
  list-style: none;
  padding: 12px 16px 20px;
  margin: 0;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
}

.task-upload {
  padding: 14px 16px 0;
}

.upload-card {
  border: 1px dashed #d6d6d6;
  border-radius: 16px;
  padding: 18px 16px 16px;
  background: #fafafa;
  text-align: center;
  display: grid;
  gap: 6px;
  box-shadow: var(--shadow-soft);
  color: #8a8f99;
  cursor: pointer;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, color 0.18s ease,
    transform 0.18s ease;
}

.upload-card.dragover {
  border-color: #b9b9b9;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.04);
  color: #6f7680;
}

.upload-card:hover {
  border-color: #c2c2c2;
}

.upload-card:focus-visible {
  outline: 2px solid rgba(0, 0, 0, 0.12);
  outline-offset: 2px;
}

.upload-title {
  font-size: 12px;
  font-weight: 500;
}

.upload-desc {
  font-size: 11px;
  color: #a3a8b1;
  margin-bottom: 2px;
  letter-spacing: 0.3px;
}

.upload-input {
  display: none;
}

.upload-plus {
  width: 34px;
  height: 34px;
  margin: 4px auto 2px;
  border-radius: 50%;
  border: 1px dashed #cfcfcf;
  display: grid;
  place-items: center;
  font-size: 20px;
  line-height: 1;
  color: #9aa0a8;
}

.eval-only {
  display: none;
}

body[data-mode="eval"] .dev-only {
  display: none !important;
}

body[data-mode="eval"] .eval-only {
  display: block;
}

body[data-mode="eval"] #taskStatus {
  display: none;
}

body[data-mode="eval"] .eval-annotation-split {
  display: grid;
}

body[data-mode="eval"] .eval-annotation-list {
  display: grid;
}

body[data-mode="dev"] .eval-annotation-column-title {
  display: none;
}

body[data-role="viewer"] .admin-only {
  display: none !important;
}

.task-list li {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid transparent;
  margin-bottom: 10px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
}

.task-list li:hover {
  border-color: var(--accent);
  background: #fff5e3;
}

.task-list li.active {
  background: #fff1dc;
  border-color: var(--accent);
}

.task-tag {
  margin-left: auto;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: #fff;
  white-space: nowrap;
}

.task-tag.completed {
  color: #1e6f5c;
  border-color: #c9e0d8;
  background: #eef7f3;
}

.task-tag.in_progress {
  color: #b26a00;
  border-color: #f0d1a5;
  background: #fff4e3;
}

.task-node {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-left: calc(var(--depth, 0) * 16px);
  margin-left: calc(var(--depth, 0) * 16px);
}

.task-dir {
  font-weight: 600;
  color: var(--muted);
}

.task-caret {
  font-size: 12px;
  color: var(--muted);
}

.task-children {
  display: flex;
  flex-direction: column;
}

.task-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.task-icon {
  font-size: 14px;
}

.task-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-meta {
  font-size: 11px;
  color: var(--muted);
  margin-left: 6px;
}

.chat-area {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.chat-group-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-self: flex-start;
  align-items: flex-start;
  max-width: 84%;
}

.chat-group-wrap.s {
  align-self: flex-end;
  align-items: flex-end;
}

.chat-group {
  display: inline-block;
  width: fit-content;
  width: max-content;
  max-width: 100%;
  padding: 12px 14px;
  border-radius: 16px;
  white-space: pre-wrap;
  word-break: keep-all;
  line-break: strict;
  overflow-wrap: break-word;
  line-height: 1.45;
  font-size: 14px;
  border: 1px solid transparent;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(47, 38, 24, 0.08);
}

.chat-role {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
  letter-spacing: 0.08em;
}

.chat-status {
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
}

.chat-tags {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 0;
  align-self: flex-start;
}

.chat-group-wrap.s .chat-tags {
  align-self: flex-end;
}

.chat-group-wrap.s .chat-tag-row {
  justify-content: flex-end;
}

.chat-tag-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--muted);
}

.chat-tag-label {
  letter-spacing: 0.04em;
}

.chat-tag {
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--tag-color) 30%, #fff);
  color: var(--ink);
  font-size: 11px;
}

.chat-group.c {
  align-self: flex-start;
  background: var(--chat-c);
  border-top-left-radius: 4px;
}

.chat-group.s {
  align-self: flex-end;
  background: var(--chat-s);
  border-top-right-radius: 4px;
}

.chat-group.active {
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(240, 125, 31, 0.3);
}

.controls {
  padding: 14px 18px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  margin-top: auto;
}

.controls-top {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.controls-bottom {
  margin-top: 0;
}

body[data-mode="dev"] .controls-top {
  order: 1;
}

body[data-mode="dev"] .controls-bottom {
  order: 0;
}

body[data-mode="eval"] .controls-top {
  order: 0;
}

body[data-mode="eval"] .controls-bottom {
  order: 1;
  margin-top: auto;
}

.controls-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 12px;
}

.controls-row .eval-export {
  margin-left: auto;
}

.controls-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 12px;
}

.annotation-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px dashed var(--border);
  background: #fffaf2;
  flex-wrap: wrap;
}

.eval-annotation-list {
  display: grid;
  gap: 12px;
  width: 100%;
}

.eval-annotation-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
}

.eval-annotation-column {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.eval-annotation-column-title {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.06em;
}

body[data-mode="eval"] .eval-annotation-list {
  display: grid;
}

.eval-annotation-card {
  border-radius: 14px;
  padding: 12px 14px;
  background: color-mix(in srgb, var(--eval-color) 26%, #fff);
  border: 1px solid color-mix(in srgb, var(--eval-color) 50%, #fff);
  box-shadow: var(--shadow-soft);
}

.eval-annotation-card.is-disabled {
  opacity: 0.55;
}

.eval-annotation-card.is-disabled .btn {
  cursor: not-allowed;
}

.eval-annotation-card.is-disabled .eval-miss {
  cursor: pointer;
  opacity: 1;
}

.eval-annotation-card.is-disabled .eval-annotation-input {
  background: #f6f1ea;
}

.eval-annotation-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.eval-annotation-title {
  font-size: 12px;
  font-weight: 600;
}

.eval-annotation-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.eval-btn {
  padding: 6px 14px;
  font-size: 12px;
}

.eval-annotation-input {
  flex: 1;
  min-width: 160px;
  border-radius: 999px;
  border: 1px solid var(--border);
  padding: 6px 12px;
  font-size: 12px;
  background: #fff;
  outline: none;
}

.eval-empty {
  font-size: 12px;
  color: var(--muted);
  padding: 8px 4px;
}

.annotation-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.annotation-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-toggle {
  background: #fff;
  border-color: var(--border);
  color: var(--ink);
}

.btn-toggle.active {
  background: #f7c27a;
  border-color: #f0a44f;
  color: #3b1b00;
}

#noteInput {
  min-width: 220px;
  flex: 1;
  border-radius: 999px;
  border: 1px solid var(--border);
  padding: 6px 12px;
  font-size: 12px;
  color: var(--ink);
  outline: none;
  background: #fff;
}

.annotation-left #annotatorInput {
  min-width: 140px;
  border-radius: 999px;
  border: 1px solid var(--border);
  padding: 6px 12px;
  font-size: 12px;
  color: var(--ink);
  outline: none;
  background: #fff;
}

.annotation-panel .hint {
  font-size: 12px;
}

.modal-content.login-content {
  width: min(260px, 90vw);
  height: auto;
  max-height: none;
  min-height: 0;
}

.login-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px 14px;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.login-field input {
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 8px 10px;
  font-size: 13px;
  outline: none;
}

.login-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.btn-danger {
  background: #f35b4c;
  border-color: #f35b4c;
  color: #fff;
}

.btn-danger:hover {
  background: #d94a3d;
  border-color: #d94a3d;
}

.modal-title {
  display: flex;
  align-items: center;
  gap: 14px;
}

.toggle,
.select {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  padding: 4px 10px;
  border-radius: 999px;
  background: #fffaf2;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
}

.toggle-switch {
  gap: 8px;
}

.toggle-switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.toggle-switch .switch {
  width: 32px;
  height: 16px;
  border-radius: 999px;
  background: #f1dcc1;
  border: 1px solid var(--border);
  position: relative;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.toggle-switch .switch::after {
  content: "";
  position: absolute;
  top: 1px;
  left: 1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s ease;
}

.toggle-switch input:checked + .switch {
  background: #f7c27a;
  border-color: #f1b45f;
}

.toggle-switch input:checked + .switch::after {
  transform: translateX(16px);
}

.select select {
  border: none;
  background: transparent;
  font-size: 12px;
  color: var(--ink);
  outline: none;
}

.select input {
  width: 60px;
  border: none;
  background: transparent;
  font-size: 12px;
  color: var(--ink);
  outline: none;
}

.result-area {
  padding: 16px 18px 20px;
  overflow-y: auto;
  flex: 1;
}

.result-block {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  background: #fffdf6;
  margin-bottom: 14px;
  box-shadow: var(--shadow-soft);
}

.eval-section-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--muted);
}

.eval-result-card {
  border-radius: 12px;
  padding: 12px;
  background: color-mix(in srgb, var(--eval-color) 28%, #fff);
  border: 1px solid color-mix(in srgb, var(--eval-color) 50%, #fff);
  margin-bottom: 10px;
}

.eval-result-title {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
}

.eval-result-list {
  display: grid;
  gap: 0;
}

.eval-result-item {
  padding: 6px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(0, 0, 0, 0.04);
  font-size: 12px;
  line-height: 1.5;
}

.eval-result-line {
  position: relative;
  display: grid;
  gap: 6px;
  padding: 2px 0;
}

.eval-result-line + .eval-result-line {
  margin-top: 6px;
  padding-top: 10px;
}

.eval-result-line + .eval-result-line::before {
  content: "";
  position: absolute;
  top: 0;
  left: 12px;
  right: 12px;
  height: 1px;
  background: rgba(0, 0, 0, 0.08);
}

.eval-result-line-items {
  display: grid;
  gap: 6px;
}

.eval-result-empty {
  align-self: center;
  justify-self: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.7);
  border: 1px dashed rgba(0, 0, 0, 0.08);
}

.result-title {
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.result-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-small {
  padding: 4px 10px;
  font-size: 12px;
}

.slow-visual {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.slow-extra {
  margin-bottom: 12px;
}

.slow-row {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 10px;
  align-items: start;
}

.slow-label {
  font-size: 12px;
  color: var(--muted);
}

.slow-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
}

.tag-muted {
  background: #f1f1f1;
  color: #5d5d5d;
}

.tag-warn {
  background: #fff3c6;
  border-color: #f2cf72;
  color: #6a4a00;
}

.tag-ok {
  background: #d6f4d5;
  border-color: #8fd08b;
  color: #1f5c2c;
}

.tag-bad {
  background: #ffd6d6;
  border-color: #f2a0a0;
  color: #7a1b1b;
}

.result-readable {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fffdf8;
  margin-bottom: 16px;
  font-size: 13px;
  line-height: 1.5;
}

.readable-title {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.readable-table {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 6px 12px;
}

.readable-key {
  color: #9a4c00;
  font-weight: 600;
}

.readable-value {
  color: var(--ink);
  white-space: pre-wrap;
}

.readable-block {
  padding: 8px 10px;
  border-left: 3px solid #f2d3a0;
  background: #fff8ee;
  border-radius: 8px;
  margin-bottom: 8px;
}

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

.readable-index {
  font-size: 12px;
  color: var(--muted);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(28, 24, 18, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}

.modal.open {
  display: flex;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(24, 20, 16, 0.35);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 60;
}

.loading-overlay.open {
  display: flex;
}

.loading-card {
  background: #fffdf8;
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 20px 26px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.loading-spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #f1d6ad;
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

.loading-text {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.06em;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.modal-content {
  background: var(--panel);
  width: min(1200px, 66vw);
  border-radius: 18px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  height: 70vh;
  max-height: 90vh;
}

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

.modal-header h2 {
  font-size: 16px;
  margin: 0;
}

.modal-body {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 16px;
  padding: 16px;
  overflow: hidden;
  flex: 1;
}

.user-modal-content {
  width: min(900px, 78vw);
  height: 70vh;
}

.user-body {
  grid-template-columns: 240px minmax(320px, 420px);
  justify-content: center;
}

.user-list-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-right: 1px solid var(--border);
  padding-right: 12px;
  overflow-y: auto;
}

.user-list-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.user-list-empty {
  font-size: 12px;
  color: var(--muted);
  padding: 6px 4px;
}

.user-item {
  background: #fff7ea;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  font-size: 12px;
}

.user-item:hover {
  border-color: var(--accent);
}

.user-item.active {
  border-color: var(--accent);
  background: #fff1dc;
}

.user-badges {
  display: flex;
  gap: 6px;
}

.user-tag {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: #fff;
}

.user-tag.is-me {
  border-color: #e7c9a2;
  color: #b35d1d;
  background: #fff4e3;
}

.user-tag.is-super {
  border-color: #f0b58b;
  color: #c76314;
  background: #ffe9d8;
}

.user-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding-right: 4px;
}

.user-selection {
  font-size: 12px;
  color: var(--muted);
  background: #fff7ea;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
}

#selectedUserLabel {
  font-weight: 600;
  color: var(--ink);
}

.user-action-card {
  border: 1px solid #eadfce;
  border-radius: 12px;
  padding: 12px;
  background: #fff8f1;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.user-action-card .readable-title {
  margin-bottom: 2px;
}

.user-field {
  display: grid;
  grid-template-columns: 72px 1fr;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}

.user-field input,
.user-field select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 13px;
  background: #fff;
}

.user-actions .btn {
  align-self: flex-start;
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 12px;
  box-shadow: none;
}

.user-actions .btn-primary {
  background: #f6e7d6;
  border-color: #ecd2b8;
  color: #9a4c00;
}

.user-actions .btn-primary:hover:enabled {
  background: #f1dcc1;
  border-color: #e5c5a6;
}

.user-actions .btn-danger {
  background: #f7e3df;
  border-color: #efc4bc;
  color: #b0493d;
}

.user-actions .btn-danger:hover:enabled {
  background: #f2d6d1;
  border-color: #e3b0a7;
}

.user-field.is-hidden {
  display: none;
}

.modal-list {
  border-right: 1px solid var(--border);
  padding-right: 12px;
  overflow-y: auto;
}

#promptList {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#promptList li {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

#promptList li.active {
  background: #fff1dc;
  border-color: var(--accent);
}

.rename-btn {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--muted);
  opacity: 0;
}

#promptList li:hover .rename-btn {
  opacity: 1;
}

.prompt-rename-input {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 6px 8px;
  font-size: 12px;
}

.modal-editor {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.prompt-tabs {
  display: inline-flex;
  gap: 8px;
  background: #f6efe6;
  padding: 6px;
  border-radius: 12px;
  border: 1px solid var(--border);
  width: fit-content;
}

.stats-body {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 16px;
  padding: 16px;
  overflow: hidden;
  flex: 1;
}

.stats-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  min-height: 0;
}

.stats-table {
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 12px;
  overflow-y: auto;
  padding-right: 4px;
}

.stats-row {
  display: grid;
  grid-template-columns: 1.6fr 90px 80px 80px 80px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  align-items: center;
  gap: 8px;
}

.stats-row.header {
  background: #fff1dc;
  font-weight: 600;
}

.stats-row:last-child {
  border-bottom: none;
}

.stats-annotator {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #fffdf8;
}

.stats-annotator-title {
  padding: 8px 10px;
  font-weight: 600;
  background: #f8efe1;
  border-bottom: 1px solid var(--border);
}

.stats-notes {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  background: #fffdf8;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.notes-block {
  margin-bottom: 12px;
}

.notes-annotator {
  margin-bottom: 14px;
}

.notes-title {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
}

.notes-version {
  font-size: 12px;
  color: var(--muted);
  margin: 6px 0 4px;
}

.notes-item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  padding: 4px 0;
  border-bottom: 1px dashed #eddcc6;
}

.notes-item:last-child {
  border-bottom: none;
}

.prompt-mode-tab,
.prompt-type-tab {
  border: 1px solid transparent;
  background: transparent;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
  color: var(--muted);
}

.prompt-mode-tab.active,
.prompt-type-tab.active {
  border-color: var(--accent);
  background: #fff;
  color: var(--text);
}

#promptEditor {
  flex: 1;
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 12px;
  font-size: 12px;
  line-height: 1.5;
  font-family: "Noto Serif SC", "STSong", "Songti SC", serif;
  resize: vertical;
  min-height: 50vh;
}

.modal-actions {
  display: flex;
  gap: 10px;
}

.result-area .empty {
  color: var(--muted);
  font-size: 13px;
}

.json-node {
  font-size: 13px;
  line-height: 1.5;
}

.json-row {
  display: flex;
  gap: 8px;
  padding: 4px 0;
}

.json-key {
  color: #9a4c00;
  min-width: 80px;
}

.json-string {
  color: #3564a6;
}

.json-number {
  color: #1e6f5c;
}

.json-boolean,
.json-null {
  color: #b02a37;
}

.json-children {
  padding-left: 16px;
}

details > summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

@media (max-width: 1100px) {
  .app {
    grid-template-columns: 1fr;
  }

  .panel {
    height: auto;
    min-height: auto;
  }

  .splitter {
    display: none;
  }
}

@media (max-width: 900px) {
  .user-modal-content {
    width: min(94vw, 900px);
    height: 84vh;
  }

  .user-body {
    grid-template-columns: 1fr;
  }

  .user-list-panel {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding-right: 0;
    padding-bottom: 12px;
  }
}
