/* Curator — hand-written stylesheet. Tokens first, then components. */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e4e7ec;
  --border-strong: #cfd4dc;
  --text: #1b1f27;
  --text-2: #4b5563;
  --muted: #6b7280;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --accent-text: #3730a3;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --danger-soft: #fef2f2;
  --danger-text: #991b1b;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --warn-text: #92400e;
  --ok: #16a34a;
  --ok-soft: #f0fdf4;
  --ok-text: #166534;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, 0.16);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --focus: 0 0 0 3px rgba(79, 70, 229, 0.25);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.01em;
}
h1 {
  font-size: 1.5rem;
}
h2 {
  font-size: 1.1rem;
}

code,
.mono {
  font-family: var(--mono);
  font-size: 0.92em;
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
}
.brand i {
  color: var(--accent);
}
.brand:hover {
  text-decoration: none;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar-user {
  color: var(--text-2);
  font-size: 0.92rem;
}

/* Page */
.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 24px 64px;
}
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.page-header .actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.crumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.5rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.crumbs a {
  color: var(--muted);
  font-weight: 500;
}
.crumb-sep {
  color: var(--border-strong);
  font-weight: 300;
}
.subtle {
  color: var(--muted);
  font-size: 0.9rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.btn:hover {
  background: var(--surface-2);
  text-decoration: none;
}
.btn i {
  font-size: 0.9em;
}
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}
.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.btn-danger:hover {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
}
.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-2);
}
.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}
.btn-ghost.is-danger:hover {
  background: var(--danger-soft);
  color: var(--danger-text);
}
.btn-icon {
  width: 36px;
  padding: 0;
  justify-content: center;
}
.btn-sm {
  height: 30px;
  padding: 0 10px;
  font-size: 0.9rem;
}
.btn-lg {
  height: 44px;
  padding: 0 20px;
  font-size: 1.05rem;
}
.btn[disabled] {
  opacity: 0.5;
  cursor: default;
}

/* Cards and tables */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-body {
  padding: 20px;
}

.table-wrap {
  overflow-x: auto;
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
.table th,
.table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table th {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--surface-2);
}
.table th a {
  color: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.table th a:hover {
  color: var(--text);
  text-decoration: none;
}
.table th a.is-active {
  color: var(--accent-text);
}
.table tbody tr:last-child td {
  border-bottom: 0;
}
.table tr[data-href] {
  cursor: pointer;
}
.table tr[data-href]:hover {
  background: var(--accent-soft);
}
.table td.num,
.table th.num {
  text-align: right;
}
.table .row-actions {
  text-align: right;
  white-space: nowrap;
}
.table .row-actions .btn {
  vertical-align: middle;
}
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 0.82rem;
}
.people {
  display: inline-flex;
  gap: 4px;
}
.people .pill {
  min-width: 26px;
  text-align: center;
}

/* Game cards */
.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.game-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  transition: box-shadow 0.12s, transform 0.12s;
}
.game-card:hover {
  box-shadow: var(--shadow-lg);
}
.game-card h2 a {
  color: var(--text);
}
.game-card .meta {
  color: var(--muted);
  font-size: 0.88rem;
  display: flex;
  gap: 12px;
}
.game-card .card-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
}

/* Empty state */
.empty {
  text-align: center;
  padding: 64px 24px;
  color: var(--muted);
}
.empty-icon {
  font-size: 2.2rem;
  color: var(--border-strong);
  margin-bottom: 12px;
  display: block;
}
.empty p {
  margin: 0 0 16px;
}

/* Alerts */
.alert {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid;
  margin-bottom: 20px;
  font-size: 0.95rem;
}
.alert i {
  margin-top: 3px;
}
.alert.is-error {
  background: var(--danger-soft);
  border-color: #fecaca;
  color: var(--danger-text);
}
.alert.is-warning {
  background: var(--warn-soft);
  border-color: #fde68a;
  color: var(--warn-text);
}
.alert.is-success {
  background: var(--ok-soft);
  border-color: #bbf7d0;
  color: var(--ok-text);
}
.alert ul {
  margin: 6px 0 0;
  padding-left: 18px;
}
.alert .alert-body {
  flex: 1;
}
.alert .alert-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

/* Forms */
.form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-2);
}
.field .hint {
  font-size: 0.85rem;
  color: var(--muted);
}
.field .field-error {
  font-size: 0.85rem;
  color: var(--danger-text);
}
.input,
.select,
.textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--accent);
  box-shadow: var(--focus);
  outline: none;
}
.input.is-invalid,
.textarea.is-invalid {
  border-color: var(--danger);
}
.input.mono {
  font-family: var(--mono);
  letter-spacing: 0.02em;
}
.textarea {
  resize: vertical;
  line-height: 1.6;
}
.textarea.editor {
  font-family: var(--mono);
  font-size: 0.95rem;
  min-height: 60vh;
  tab-size: 2;
}
.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
}
.replace-bar {
  display: grid;
  grid-template-columns: 1fr 1fr auto minmax(60px, auto);
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.replace-bar[hidden] {
  display: none;
}
@media (max-width: 700px) {
  .replace-bar {
    grid-template-columns: 1fr 1fr;
  }
}
.editor-area {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: stretch;
}
.editor-area.is-split {
  grid-template-columns: 1fr 1fr;
}
.preview {
  display: flex;
  min-height: 60vh;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #14161b;
}
.preview[hidden] {
  display: none;
}
.preview iframe {
  flex: 1;
  width: 100%;
  border: 0;
  background: transparent;
}
.btn[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent-text);
}
.form-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.form-actions .spacer {
  flex: 1;
}
.form-row {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 16px;
  align-items: start;
}
@media (max-width: 700px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}
.kbd {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-2);
}

/* Login */
.login {
  min-height: 80vh;
  display: grid;
  place-items: center;
}
.login-card {
  text-align: center;
  padding: 40px 48px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}
.login-icon {
  font-size: 2.4rem;
  color: var(--accent);
}

/* Dialog */
dialog.confirm {
  border: 0;
  border-radius: var(--radius);
  padding: 24px;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
}
dialog.confirm::backdrop {
  background: rgba(17, 24, 39, 0.45);
}
dialog.confirm p {
  margin: 0 0 18px;
  font-size: 1rem;
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Help dialog (formatting reference) */
dialog.help {
  border: 0;
  border-radius: var(--radius);
  padding: 0;
  width: 520px;
  max-width: calc(100vw - 32px);
  box-shadow: var(--shadow-lg);
}
dialog.help::backdrop {
  background: rgba(17, 24, 39, 0.45);
}
.help-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 12px 14px 20px;
  border-bottom: 1px solid var(--border);
}
.help-table {
  width: 100%;
  border-collapse: collapse;
}
.help-table td {
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  font-size: 0.92rem;
}
.help-table tr:last-child td {
  border-bottom: 0;
}
.help-table td:first-child {
  width: 50%;
  white-space: nowrap;
}
.help-table code {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  line-height: 1.6;
}
.help-table td:last-child {
  color: var(--text-2);
}

/* History / diffs */
.revision {
  margin-bottom: 20px;
}
.revision-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
}
.revision-header .who {
  font-weight: 600;
}
.revision-header .when {
  color: var(--muted);
}
.revision-header .rename {
  margin-left: auto;
  color: var(--text-2);
}
.diff {
  margin: 0;
  padding: 8px 0;
  font-family: var(--mono);
  font-size: 0.86rem;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre;
}
.diff .line {
  display: flex;
  padding: 0 16px;
}
.diff .line-marker {
  width: 18px;
  flex-shrink: 0;
  color: var(--muted);
  user-select: none;
}
.diff .line.add {
  background: #ecfdf5;
  color: #065f46;
}
.diff .line.del {
  background: #fef2f2;
  color: #991b1b;
}
.diff .line.same {
  color: var(--text-2);
}
.diff .unchanged-note {
  padding: 4px 16px;
  color: var(--muted);
  font-style: italic;
}
