/* ================================================================
   Skill Admin – Database management tool styles
   ================================================================ */

:root {
  --bg: #f5f3ef;
  --surface: #ffffff;
  --surface-raised: #faf9f6;
  --ink: #1a1a1a;
  --ink-2: #555049;
  --ink-3: #908980;
  --border: #e3ded5;
  --border-light: #edebe6;
  --accent: #0a7c6c;
  --accent-hover: #08685a;
  --accent-bg: rgba(10, 124, 108, 0.07);
  --accent-bg-strong: rgba(10, 124, 108, 0.13);
  --header-tint: rgba(255, 251, 244, 0.92);
  --header-shadow: rgba(76, 64, 46, 0.08);
  --header-band: linear-gradient(90deg, rgba(10, 124, 108, 0.2), rgba(186, 142, 66, 0.18) 54%, rgba(26, 26, 26, 0.08));
  --danger: #b91c1c;
  --danger-hover: #991b1b;
  --danger-bg: rgba(185, 28, 28, 0.08);
  --warn: #92400e;
  --warn-bg: rgba(146, 64, 14, 0.08);
  --radius: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
  --shadow-xl: 0 16px 50px rgba(0,0,0,0.18);
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --drawer-width: clamp(860px, 62vw, 1240px);
}

*, *::before, *::after { box-sizing: border-box; }
html { height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
.login-page {
  background:
    radial-gradient(circle at top left, rgba(10, 124, 108, 0.18), transparent 28%),
    radial-gradient(circle at bottom right, rgba(11, 52, 48, 0.22), transparent 24%),
    linear-gradient(135deg, #f6f0e6 0%, #ece6da 45%, #e4ddd1 100%);
}
code {
  font-family: var(--font-mono);
  font-size: 12px;
}
::selection { background: var(--accent-bg-strong); }

/* ── Buttons ──────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius);
  padding: 8px 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 150ms var(--ease);
  line-height: 1.3;
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}
.btn svg { flex-shrink: 0; }
.btn-primary {
  background: linear-gradient(180deg, #22201d 0%, #171512 100%);
  color: #fff;
  box-shadow: 0 10px 20px -18px rgba(0, 0, 0, 0.95);
}
.btn-primary:hover {
  background: linear-gradient(180deg, #2d2a26 0%, #191713 100%);
}
.btn-ghost {
  background: transparent;
  color: var(--ink-2);
}
.btn-ghost:hover { background: rgba(0,0,0,0.06); }
.btn-outline {
  background: var(--surface);
  color: var(--ink-2);
  border: 1px solid var(--border);
}
.btn-outline:hover { border-color: var(--ink-3); background: rgba(255, 255, 255, 0.92); }
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: var(--danger-hover); }
.btn-warn {
  background: var(--warn-bg);
  color: var(--warn);
  border: 1px solid rgba(146, 64, 14, 0.18);
}
.btn-warn:hover { background: rgba(146, 64, 14, 0.14); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--ink-3);
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 150ms var(--ease);
  padding: 0;
  font: inherit;
}
.btn-icon:hover { background: rgba(0,0,0,0.06); color: var(--ink); }
.btn-icon-sm { width: 26px; height: 26px; }

/* ── Header ───────────────────────────────────────── */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 24px 13px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(255, 250, 242, 0.94)),
    var(--header-tint);
  border-bottom: 1px solid rgba(108, 92, 67, 0.14);
  box-shadow: 0 10px 28px -24px var(--header-shadow);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 100;
}
.app-header::after {
  content: '';
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: -1px;
  height: 2px;
  border-radius: 999px;
  background: var(--header-band);
  opacity: 0.9;
  pointer-events: none;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}
.logo {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: #171512;
}
.db-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: #21584f;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-mono);
  border: 1px solid rgba(10, 124, 108, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}
.db-badge .sep { opacity: 0.4; margin: 0 1px; }
.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.header-right .btn-ghost {
  color: #413a32;
}
.header-right .btn-ghost:hover {
  background: rgba(67, 55, 37, 0.06);
}
.inline-form {
  margin: 0;
}

/* ── Toolbar ──────────────────────────────────────── */

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 24px 10px;
  background: linear-gradient(180deg, rgba(255, 251, 245, 0.9), rgba(255, 255, 255, 0.82));
  border-bottom: 1px solid rgba(146, 133, 112, 0.14);
}
.toolbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 0;
}
.search-box {
  position: relative;
  flex: 1;
  max-width: 420px;
}
.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-3);
  pointer-events: none;
}
.search-box input {
  width: 100%;
  padding: 7px 12px 7px 34px;
  border: 1px solid rgba(133, 119, 95, 0.16);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.74);
  transition: border-color 150ms var(--ease), box-shadow 150ms var(--ease), background 150ms var(--ease);
}
.search-box input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}
.search-box input::placeholder { color: var(--ink-3); }
.toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}
.toggle-label input[type="checkbox"] {
  accent-color: var(--accent);
}
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.record-count {
  font-size: 12px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.export-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
.export-group select {
  padding: 5px 8px;
  border: 1px solid rgba(133, 119, 95, 0.16);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink-2);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

/* ── Batch bar ────────────────────────────────────── */

.batch-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 24px;
  background: var(--accent-bg);
  border-bottom: 1px solid rgba(10, 124, 108, 0.15);
  font-size: 13px;
  color: var(--accent);
  font-weight: 500;
  animation: slideDown 200ms var(--ease);
}
.batch-bar.hidden { display: none; }
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Table ────────────────────────────────────────── */

.table-container {
  padding: 0 24px 24px;
  margin-top: 1px;
}
.table-scroll {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
table {
  width: 100%;
  border-collapse: collapse;
}
thead {
  background: var(--surface-raised);
  position: sticky;
  top: 0;
  z-index: 2;
}
th {
  padding: 9px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
}
th[aria-sort="ascending"],
th[aria-sort="descending"] {
  background: rgba(10, 124, 108, 0.06);
}
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
  font-size: 13px;
}
tbody tr {
  cursor: pointer;
  transition: background 100ms var(--ease);
}
tbody tr:hover { background: var(--accent-bg); }
tbody tr.active {
  background: var(--accent-bg-strong);
}
tbody tr:last-child td { border-bottom: none; }
.col-check { width: 40px; text-align: center; }
.col-check input { cursor: pointer; accent-color: var(--accent); }
.col-name { font-weight: 500; }
.col-path code {
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(0,0,0,0.04);
  color: var(--ink-2);
}
.col-type { color: var(--ink-2); }
.col-created,
.col-updated {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
td.col-created,
td.col-updated {
  color: var(--ink-2);
  font-weight: 500;
}
th.col-created,
th.col-updated {
  color: var(--ink-3);
}
.sort-button {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  cursor: pointer;
}
.sort-button:hover {
  color: var(--ink-2);
}
.sort-button.active {
  color: var(--accent);
}
.sort-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  color: var(--ink-3);
  font-size: 10px;
  line-height: 1;
}
.sort-button.active .sort-indicator {
  color: var(--accent);
}
.sort-indicator::before {
  content: "↕";
}
.sort-button[data-direction="asc"] .sort-indicator::before {
  content: "↑";
}
.sort-button[data-direction="desc"] .sort-indicator::before {
  content: "↓";
}
.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.status-pill.active {
  background: var(--accent-bg-strong);
  color: var(--accent);
}
.status-pill.deleted {
  background: var(--danger-bg);
  color: var(--danger);
}
.table-summary {
  margin: 10px 4px 0;
  font-size: 12px;
  color: var(--ink-3);
}
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--ink-3);
}
.empty-state.hidden { display: none; }
.empty-state p { margin: 12px 0 0; }

/* ── Drawer ───────────────────────────────────────── */

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.25);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 250ms var(--ease);
  backdrop-filter: blur(2px);
}
.drawer-overlay.open {
  opacity: 1;
  pointer-events: auto;
}
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--drawer-width);
  max-width: 100vw;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-xl);
  z-index: 210;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 280ms var(--ease);
}
.drawer.open {
  transform: translateX(0);
}
.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}
.drawer-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.drawer-badge {
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--accent-bg-strong);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.drawer-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px 24px;
  background:
    linear-gradient(180deg, rgba(250, 248, 244, 0.95), rgba(245, 243, 239, 0.82)),
    var(--bg);
}
.drawer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-raised);
  flex-shrink: 0;
}
.footer-left, .footer-right {
  display: flex;
  align-items: center;
  gap: 6px;
}
.footer-right.hidden { display: none; }

.drawer-layout {
  display: block;
}
.drawer-view {
  min-width: 0;
}

/* ── Editor cards ─────────────────────────────────── */

.editor-card {
  border: 1px solid rgba(133, 119, 95, 0.14);
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(250, 249, 246, 0.92));
  box-shadow: 0 10px 30px -26px rgba(54, 43, 26, 0.32);
}
.editor-form-card {
  padding: 18px 18px 12px;
}
.editor-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(133, 119, 95, 0.12);
}
.editor-card-head.compact {
  margin-bottom: 12px;
  padding-bottom: 10px;
}
.editor-card-head h3 {
  margin: 4px 0 0;
  font-size: 16px;
  letter-spacing: -0.02em;
}
.editor-card-kicker {
  margin: 0;
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.editor-card-note {
  margin: 0;
  max-width: 28ch;
  color: var(--ink-3);
  font-size: 12px;
  line-height: 1.55;
  text-align: right;
}

/* ── Record meta ──────────────────────────────────── */

.record-meta {
  padding: 16px;
  font-size: 12px;
}
.record-meta-inline {
  margin-bottom: 16px;
}
.record-meta.compact {
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
}
.record-meta.hidden { display: none; }
.record-meta-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px 12px;
}
.record-meta-inline .record-meta-grid .meta-item:nth-child(2) {
  grid-column: span 2;
}
.record-meta-grid.compact {
  gap: 6px 10px;
}
.meta-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 10px 11px;
  border-radius: 10px;
  background: rgba(248, 245, 239, 0.82);
  border: 1px solid rgba(133, 119, 95, 0.1);
}
.meta-label {
  color: var(--ink-3);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.meta-item code, .meta-item span:not(.meta-label) {
  color: var(--ink-2);
  word-break: break-all;
}

/* ── Form fields ──────────────────────────────────── */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.field > span {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
}
.field > span em {
  color: var(--danger);
  font-style: normal;
}
.field input[type="text"],
.field input[type="password"],
.field select,
.field textarea,
.field input[type="file"] {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  line-height: 1.4;
  transition: border-color 150ms var(--ease), box-shadow 150ms var(--ease);
}
.field input[type="text"],
.field input[type="password"],
.field select {
  min-height: 40px;
}
.field select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink-3) 50%),
    linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 2px),
    calc(100% - 12px) calc(50% - 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 32px;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}
.field-readonly input[readonly] {
  background: linear-gradient(180deg, rgba(247, 245, 240, 0.92), rgba(243, 240, 234, 0.96));
  color: var(--ink-2);
  border-style: dashed;
  font-family: var(--font-mono);
}
.field textarea { resize: vertical; font-family: var(--font-mono); font-size: 12px; line-height: 1.6; }
#skill-content {
  min-height: clamp(400px, 54vh, 820px);
}
#child-content {
  min-height: clamp(400px, 54vh, 820px);
}
.field-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
}
.field-check input { accent-color: var(--accent); cursor: pointer; }
.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.form-row-2 .field { margin-bottom: 14px; }

/* ── Section collapse ─────────────────────────────── */

.section-collapse {
  border: 1px solid var(--border-light);
  border-radius: 16px;
  margin-bottom: 0;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(250, 249, 246, 0.92));
  box-shadow: 0 10px 30px -26px rgba(54, 43, 26, 0.32);
}
.section-collapse summary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  color: var(--ink-2);
  background: var(--surface-raised);
  list-style: none;
  transition: background 100ms;
}
.side-section summary {
  min-height: 48px;
}
.section-collapse summary::-webkit-details-marker { display: none; }
.section-collapse summary:hover { background: var(--border-light); }
.section-collapse[open] summary svg { transform: rotate(90deg); }
.section-collapse summary svg { transition: transform 200ms var(--ease); flex-shrink: 0; }
.count-badge {
  margin-left: auto;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent-bg-strong);
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
}
.collapse-body {
  padding: 14px;
  background: rgba(255, 255, 255, 0.64);
}

/* ── Child files ──────────────────────────────────── */

.child-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.section-note {
  margin: 0;
  color: var(--ink-3);
  font-size: 12px;
  line-height: 1.5;
}
.child-toolbar.compact {
  justify-content: flex-end;
}
.child-list { display: flex; flex-direction: column; gap: 4px; }
.child-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 100ms;
  font-size: 13px;
}
.child-item:hover { background: var(--accent-bg); }
.child-item.active { background: var(--accent-bg-strong); }
.child-item code { flex: 1; min-width: 0; word-break: break-all; }
.child-item .status-pill { flex-shrink: 0; }
.child-empty {
  text-align: center;
  padding: 16px;
  color: var(--ink-3);
  font-size: 13px;
  border: 1px dashed rgba(133, 119, 95, 0.2);
  border-radius: 12px;
  background: rgba(248, 245, 239, 0.7);
}
.child-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* ── JSON preview ─────────────────────────────────── */

.json-pre {
  margin: 0;
  max-height: 420px;
  overflow: auto;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  background: var(--surface-raised);
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Modal ────────────────────────────────────────── */

dialog.modal {
  position: fixed;
  border: none;
  border-radius: var(--radius-lg);
  padding: 0;
  background: var(--surface);
  box-shadow: var(--shadow-xl);
  max-width: 480px;
  width: calc(100vw - 48px);
  z-index: 300;
  animation: modalIn 200ms var(--ease);
}
dialog.modal::backdrop {
  background: rgba(0,0,0,0.3);
  backdrop-filter: blur(2px);
}
.modal-sm { max-width: 400px; }
.modal-xl { max-width: 1120px; }
#reference-modal {
  width: min(1460px, calc(100vw - 28px));
  max-width: min(1460px, calc(100vw - 28px));
  height: min(900px, calc(100vh - 28px));
  max-height: calc(100vh - 28px);
}
#reference-modal[open] {
  display: flex;
  flex-direction: column;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
}
.modal-header h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 20px; }
#reference-modal .modal-body {
  flex: 1;
  overflow: auto;
  padding: 18px 20px 20px;
}
.modal-desc { margin: 0 0 16px; color: var(--ink-2); line-height: 1.55; }
.modal-body code {
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(0,0,0,0.06);
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border-light);
  background: var(--surface-raised);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.reference-tabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  padding: 6px;
  border-radius: 16px;
  background: rgba(245, 240, 232, 0.9);
  border: 1px solid rgba(133, 119, 95, 0.12);
}
.reference-tab {
  border: none;
  border-radius: 12px;
  padding: 9px 14px;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 150ms var(--ease), color 150ms var(--ease), box-shadow 150ms var(--ease);
}
.reference-tab:hover {
  background: rgba(255, 255, 255, 0.7);
}
.reference-tab.active {
  background: linear-gradient(180deg, #113d37 0%, #0b302b 100%);
  color: #eef7f3;
  box-shadow: 0 10px 22px -18px rgba(11, 48, 43, 0.6);
}
.reference-panels {
  min-width: 0;
}
.reference-panel {
  min-width: 0;
  min-height: 100%;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid rgba(133, 119, 95, 0.12);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(249, 247, 242, 0.82));
  box-shadow: 0 14px 30px -28px rgba(44, 35, 21, 0.35);
}
.reference-kicker {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.reference-panel h4 {
  margin: 0 0 10px;
  font-size: 16px;
  letter-spacing: -0.02em;
}
.reference-copy {
  margin: 0 0 12px;
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-line;
}
.reference-subtitle {
  margin: 16px 0 8px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.reference-panel > .reference-subtitle:first-of-type {
  margin-top: 0;
}
.reference-code {
  margin: 0;
  max-height: min(62vh, 620px);
  overflow: auto;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid rgba(133, 119, 95, 0.12);
  background: #f5f1ea;
  color: #2b2620;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.7;
  white-space: pre;
}
.reference-code code {
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
}

/* ── Toast ────────────────────────────────────────── */

.toast-container {
  position: fixed;
  bottom: 20px;
  right: 24px;
  z-index: 400;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
}

/* ── Login page ───────────────────────────────────── */

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}
.login-card {
  position: relative;
  width: min(980px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(360px, 0.88fr);
  overflow: hidden;
  border: 1px solid rgba(17, 24, 39, 0.08);
  border-radius: 28px;
  background: rgba(255, 251, 245, 0.78);
  box-shadow: 0 22px 70px rgba(41, 34, 26, 0.16);
  backdrop-filter: blur(14px);
}
.login-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(120deg, rgba(10, 124, 108, 0.08), transparent 38%),
    linear-gradient(0deg, rgba(255, 255, 255, 0.35), transparent 45%);
  pointer-events: none;
}
.login-eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.login-hero {
  position: relative;
  padding: 42px 40px 38px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.56), rgba(255, 255, 255, 0.16)),
    linear-gradient(135deg, rgba(10, 124, 108, 0.1), rgba(10, 124, 108, 0.02));
  border-right: 1px solid rgba(17, 24, 39, 0.08);
}
.login-hero::after {
  content: "";
  position: absolute;
  right: -80px;
  bottom: -110px;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(10, 124, 108, 0.16), transparent 68%);
}
.login-hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.login-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(11, 52, 48, 0.9);
  color: #eef7f3;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.login-hero h1 {
  margin: 14px 0 14px;
  max-width: 11ch;
  font-size: clamp(34px, 5vw, 56px);
  line-height: 0.96;
  letter-spacing: -0.05em;
  text-wrap: balance;
}
.login-copy {
  margin: 0;
  color: var(--ink-2);
  max-width: 40ch;
  font-size: 15px;
  line-height: 1.7;
}
.login-copy code {
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--accent-bg);
  color: var(--accent);
}
.login-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 28px;
}
.login-meta-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 15px;
  border: 1px solid rgba(17, 24, 39, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.68);
  box-shadow: 0 10px 24px rgba(41, 34, 26, 0.06);
}
.login-meta-card code,
.login-meta-card span:not(.login-meta-label) {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
}
.login-meta-card-wide {
  grid-column: 1 / -1;
}
.login-meta-label {
  color: var(--ink-3);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}
.login-form-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 40px 36px;
}
.login-form-head h2 {
  margin: 0;
  font-size: 24px;
  letter-spacing: -0.03em;
}
.login-form-head p {
  margin: 10px 0 0;
  color: var(--ink-2);
  line-height: 1.6;
}
.login-form {
  margin-top: 24px;
}
.login-submit {
  width: 100%;
  justify-content: center;
  margin-top: 6px;
  padding-top: 11px;
  padding-bottom: 11px;
  border-radius: 12px;
  background: linear-gradient(180deg, #113d37 0%, #0b302b 100%);
  box-shadow: 0 12px 24px rgba(11, 48, 43, 0.22);
}
.login-submit:hover {
  background: linear-gradient(180deg, #145149 0%, #0d3731 100%);
}
.login-error {
  margin-top: 18px;
  padding: 12px 13px;
  border: 1px solid rgba(185, 28, 28, 0.18);
  border-radius: 14px;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 13px;
  font-weight: 500;
}
.login-note {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-top: 18px;
  color: var(--ink-3);
  font-size: 12px;
  line-height: 1.6;
}
.login-note-dot {
  width: 8px;
  height: 8px;
  margin-top: 5px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 6px rgba(10, 124, 108, 0.12);
}
.toast {
  pointer-events: auto;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn 250ms var(--ease);
  max-width: 400px;
  line-height: 1.45;
}
.toast.error {
  background: var(--danger);
}
.toast.out {
  animation: toastOut 200ms var(--ease) forwards;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(8px) scale(0.95); }
}

/* ── Loading state ────────────────────────────────── */

.loading {
  opacity: 0.6;
  pointer-events: none;
}

/* ── Responsive ───────────────────────────────────── */

@media (max-width: 768px) {
  .app-header { padding: 10px 16px; }
  .toolbar { padding: 8px 16px; flex-wrap: wrap; }
  .toolbar-left { flex-wrap: wrap; }
  .search-box { max-width: none; }
  .toolbar-right { flex-wrap: wrap; }
  .table-container { padding: 0 16px 16px; }
  .batch-bar { padding: 8px 16px; }
  .drawer { --drawer-width: 100vw; }
  .drawer-body { padding: 14px 14px 18px; }
  .drawer-layout { display: block; }
  .editor-form-card,
  .record-meta { padding: 14px; }
  .editor-card-head {
    flex-direction: column;
    align-items: flex-start;
  }
  .editor-card-note {
    max-width: none;
    text-align: left;
  }
  #skill-content,
  #child-content {
    min-height: 40vh;
  }
  .form-row-2 { grid-template-columns: 1fr; }
  .record-meta-grid { grid-template-columns: 1fr; }
  .record-meta-inline .record-meta-grid .meta-item:nth-child(2) {
    grid-column: auto;
  }
  .header-right .btn span { display: none; }
  .login-shell { padding: 18px; }
  .login-card {
    grid-template-columns: 1fr;
    border-radius: 22px;
  }
  .login-hero {
    padding: 28px 24px 24px;
    border-right: none;
    border-bottom: 1px solid rgba(17, 24, 39, 0.08);
  }
  .login-hero-top {
    flex-direction: column;
    align-items: flex-start;
  }
  .login-hero h1 {
    max-width: none;
    font-size: clamp(30px, 12vw, 44px);
  }
  .login-meta-grid {
    grid-template-columns: 1fr;
  }
  .login-meta-card-wide {
    grid-column: auto;
  }
  .login-form-panel {
    padding: 26px 24px 28px;
  }
  .reference-tabs {
    display: grid;
    grid-template-columns: 1fr;
  }
  #reference-modal {
    width: calc(100vw - 12px);
    max-width: calc(100vw - 12px);
    height: calc(100vh - 12px);
    max-height: calc(100vh - 12px);
  }
}

/* ── Utility ──────────────────────────────────────── */

/* ── Tree table rows ──────────────────────────────── */

.col-toggle { width: 36px; text-align: center; padding-left: 4px; padding-right: 0; }
.row-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: none;
  background: none;
  color: var(--ink-3);
  cursor: pointer;
  padding: 3px;
  border-radius: 4px;
  transition: all 150ms var(--ease);
  font: inherit;
  line-height: 1;
}
.row-toggle:hover { background: rgba(0,0,0,0.07); color: var(--ink); }
.row-toggle svg {
  transition: transform 200ms var(--ease);
  flex-shrink: 0;
}
.row-toggle.expanded svg { transform: rotate(90deg); }
.row-toggle .child-badge {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  min-width: 14px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-bg-strong);
  border-radius: 999px;
  padding: 0 3px;
  line-height: 1;
}
.row-toggle.no-children {
  opacity: 0.25;
  cursor: default;
}
.row-toggle.no-children:hover { background: none; color: var(--ink-3); }

/* Child sub-rows */
.child-row {
  background: var(--surface-raised);
}
.child-row:hover { background: var(--border-light) !important; }
.child-row td {
  font-size: 12px;
  color: var(--ink-2);
  padding-top: 6px;
  padding-bottom: 6px;
  border-bottom-color: var(--border-light);
}
.child-row:last-child td,
.child-row + tr:not(.child-row) td { /* reset bottom border before next skill */ }
.child-indent {
  text-align: center;
  color: var(--border);
  font-family: var(--font-mono);
  font-size: 13px;
  user-select: none;
  padding-left: 2px;
  padding-right: 0;
  width: 36px;
}
.child-row .col-name { font-weight: 400 !important; }
.child-row .col-path code {
  background: rgba(0,0,0,0.03);
  font-size: 11px;
}
.child-empty-cell {
  color: var(--ink-3);
  font-style: italic;
  font-size: 12px;
}
/* Loading spinner for child rows */
.child-loading-cell {
  color: var(--ink-3);
  font-size: 12px;
}
.child-loading-cell::before {
  content: '';
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 600ms linear infinite;
  margin-right: 6px;
  vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }
