@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,700&family=IBM+Plex+Mono:wght@400;500;600&family=Manrope:wght@400;500;700;800&display=swap");

:root {
  --bg: #f7f2e7;
  --ink: #1f2b2e;
  --ink-soft: #425459;
  --ink-faint: #6f7e83;
  --panel: #fffaf0;
  --panel-2: #fdf7eb;
  --line: #d8cab0;
  --accent: #0d9488;
  --accent-soft: #9be7df;
  --danger: #af2f28;
  --danger-soft: #f8c3be;
  --green-link: #0f9f6e;
  --token: #fff4db;
  --token-hover: #ffe5b3;
  --token-active: #fed38e;
  --token-deleted: #e5e0d5;
  --shadow: 0 14px 30px rgba(48, 32, 13, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(1100px 400px at 15% -10%, rgba(13, 148, 136, 0.18), transparent 62%),
    radial-gradient(900px 360px at 100% 0%, rgba(246, 170, 78, 0.16), transparent 55%),
    linear-gradient(180deg, #f3ecdf 0%, var(--bg) 100%);
  font-family: "Manrope", "Segoe UI", sans-serif;
}

.app-shell {
  min-height: 100%;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(251, 244, 230, 0.93);
  backdrop-filter: blur(8px);
}

.brand h1 {
  margin: 0;
  font-family: "Fraunces", serif;
  font-weight: 700;
  font-size: 1.38rem;
  letter-spacing: 0.2px;
}

.brand-kicker {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.77rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.toolbar {
  margin-top: 10px;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(300px, 1.2fr) minmax(280px, 1fr);
  gap: 12px;
  align-items: end;
}

.field {
  display: grid;
  gap: 5px;
}

.field span {
  color: var(--ink-faint);
  font-size: 0.77rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

select,
input[type="number"],
input[type="password"] {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.95rem;
  color: var(--ink);
  background: white;
  outline: none;
}

select:focus,
input[type="number"]:focus,
input[type="password"]:focus {
  border-color: color-mix(in srgb, var(--accent) 45%, white);
  box-shadow: 0 0 0 4px rgba(13, 148, 136, 0.13);
}

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

audio {
  width: 100%;
}

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

.btn {
  border: 1px solid color-mix(in srgb, var(--accent) 36%, #0000);
  background: var(--accent);
  color: #f5fffd;
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease;
}

.btn:hover {
  filter: brightness(1.06);
}

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

.btn-ghost {
  background: white;
  border-color: var(--line);
  color: var(--ink);
}

.btn-danger {
  background: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 45%, #0000);
  color: #fff4f2;
}

.meta-row {
  margin-top: 10px;
  display: grid;
  grid-template-columns: minmax(280px, 1fr) 2fr;
  gap: 10px;
}

.status {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.8rem;
  white-space: pre-wrap;
}

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

.badge {
  border-radius: 999px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink-soft);
  font-size: 0.79rem;
  font-family: "IBM Plex Mono", monospace;
}

.main {
  padding: 14px 16px 18px 16px;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 10px;
}

.legend {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 10px 12px;
  color: var(--ink-soft);
  font-size: 0.87rem;
}

.board {
  min-height: 0;
  height: calc(100vh - 270px);
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 190px minmax(260px, 1fr);
  overflow: auto;
  box-shadow: var(--shadow);
}

.pane {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
}

.pane-pred {
  border-right: 1px solid var(--line);
}

.pane-gt {
  border-left: 1px solid var(--line);
}

.pane-header {
  position: sticky;
  top: 0;
  z-index: 4;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 251, 241, 0.95);
  backdrop-filter: blur(5px);
  padding: 11px 12px;
}

.pane-header h2 {
  margin: 0;
  font-size: 1rem;
  font-family: "Fraunces", serif;
}

.pane-header p {
  margin: 4px 0 0 0;
  color: var(--ink-faint);
  font-size: 0.8rem;
}

.tokens {
  padding: 10px;
  line-height: 1.4;
}

.token {
  display: inline-flex;
  align-items: center;
  margin: 0 5px 8px 0;
  border: 1px solid color-mix(in srgb, var(--line) 90%, #0000);
  border-radius: 11px;
  background: var(--token);
  color: var(--ink);
  padding: 5px 7px;
  font-size: 0.95rem;
  cursor: pointer;
  user-select: none;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.08s ease;
}

.token:hover {
  background: var(--token-hover);
}

.token:active {
  transform: scale(0.99);
}

.token.selected {
  border-color: color-mix(in srgb, var(--accent) 48%, #0000);
  background: var(--token-active);
}

.token.deleted {
  color: #7d8488;
  background: var(--token-deleted);
  text-decoration: line-through;
  text-decoration-thickness: 1.3px;
}

.token.linked {
  box-shadow: inset 0 -2px 0 color-mix(in srgb, var(--green-link) 64%, #0000);
}

.token.dragging {
  opacity: 0.38;
}

.lane {
  position: sticky;
  left: 0;
  right: 0;
  align-self: start;
  min-height: 100%;
  border-left: 1px dashed color-mix(in srgb, var(--line) 75%, #0000);
  border-right: 1px dashed color-mix(in srgb, var(--line) 75%, #0000);
  background: linear-gradient(180deg, rgba(13, 148, 136, 0.05) 0%, rgba(13, 148, 136, 0.02) 100%);
}

#linkSvg {
  width: 100%;
  height: 100%;
  min-height: 100%;
  overflow: visible;
}

.link-path {
  fill: none;
  stroke: var(--green-link);
  stroke-width: 2.2;
  opacity: 0.64;
  cursor: pointer;
  transition: opacity 0.12s ease, stroke-width 0.12s ease;
}

.link-path:hover {
  opacity: 0.96;
}

.link-path.selected {
  stroke-width: 4;
  opacity: 1;
}

.link-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 13;
  cursor: pointer;
}

.modal {
  border: none;
  border-radius: 16px;
  padding: 0;
  width: min(880px, calc(100% - 24px));
  background: #fffdf7;
  color: var(--ink);
  box-shadow: 0 28px 50px rgba(22, 15, 5, 0.24);
}

.modal::backdrop {
  background: rgba(21, 13, 4, 0.4);
}

.modal-card {
  margin: 0;
  padding: 14px;
  display: grid;
  gap: 10px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.modal-head h3 {
  margin: 0;
  font-family: "Fraunces", serif;
}

.modal-copy {
  margin: 0;
  color: var(--ink-soft);
}

.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.range-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.preview {
  margin: 0;
  min-height: 200px;
  max-height: 340px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffaf0;
  padding: 10px 12px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.82rem;
  line-height: 1.45;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.login-body {
  display: grid;
  place-items: center;
}

.login-wrap {
  width: min(560px, calc(100% - 24px));
}

.login-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  background: rgba(255, 251, 241, 0.95);
  box-shadow: var(--shadow);
}

.brand-login p {
  margin-top: 6px;
  color: var(--ink-faint);
}

.login-form {
  margin-top: 12px;
  display: grid;
  gap: 12px;
}

.login-status {
  min-height: 38px;
}

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

  .meta-row {
    grid-template-columns: 1fr;
  }

  .board {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 76vh;
  }

  .lane {
    min-height: 120px;
    border-top: 1px dashed var(--line);
    border-bottom: 1px dashed var(--line);
    border-left: none;
    border-right: none;
  }

  .pane-pred,
  .pane-gt {
    border: none;
  }

  .modal-grid {
    grid-template-columns: 1fr;
  }
}
