/* Framehouse base: tokens, reset, type, controls shared by studio, gallery and portal. */
:root {
  --paper: #f6f3ee;
  --paper-2: #efeae2;
  --surface: #ffffff;
  --surface-2: #fbf9f5;
  --ink: #1e1c19;
  --ink-2: #5d5850;
  --ink-3: #8e887e;
  --line: #e8e2d8;
  --line-2: #d8cfc1;
  --accent: #8a6a55;
  --accent-ink: #ffffff;
  --success: #4c7a57;
  --success-bg: #e8f0e8;
  --warning: #a8761f;
  --warning-bg: #f6ecd8;
  --danger: #a3453c;
  --danger-bg: #f6e3df;
  --info: #4d6c8c;
  --info-bg: #e3ebf3;

  --font-display: 'Cormorant Garamond', 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;
  --font-ui: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(30, 28, 25, 0.06);
  --shadow: 0 1px 2px rgba(30, 28, 25, 0.05), 0 8px 24px rgba(30, 28, 25, 0.06);
  --shadow-lg: 0 24px 60px rgba(30, 28, 25, 0.18);
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, video, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 500; line-height: 1.15; }
p { margin: 0; }
[hidden] { display: none !important; }
::selection { background: color-mix(in srgb, var(--accent) 25%, transparent); }

.display { font-family: var(--font-display); font-weight: 500; letter-spacing: -0.01em; }
.eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.muted { color: var(--ink-2); }
.subtle { color: var(--ink-3); }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid transparent;
  font-size: 13.5px; font-weight: 500; line-height: 1; white-space: nowrap; cursor: pointer; text-decoration: none;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), color 0.15s var(--ease), box-shadow 0.15s var(--ease), transform 0.1s;
  user-select: none;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn-primary { background: var(--ink); color: #f7f3ec; }
.btn-primary:hover:not(:disabled) { background: #33302b; }
.btn-accent { background: var(--accent); color: var(--accent-ink); }
.btn-accent:hover:not(:disabled) { filter: brightness(1.06); }
.btn-secondary { background: var(--surface); border-color: var(--line-2); color: var(--ink); box-shadow: var(--shadow-sm); }
.btn-secondary:hover:not(:disabled) { border-color: var(--ink-3); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover:not(:disabled) { background: color-mix(in srgb, var(--ink) 6%, transparent); color: var(--ink); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(1.08); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 14.5px; border-radius: 10px; }
.btn-icon { width: 36px; padding: 0; }
.btn-icon.btn-sm { width: 30px; }
.btn-block { width: 100%; }

/* ---------- form controls ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
.field-hint { font-size: 12px; color: var(--ink-3); }
.input, .select, .textarea {
  width: 100%; min-width: 0; height: 38px; padding: 0 12px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 8px;
  outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
.textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; line-height: 1.55; }
.select {
  appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238e887e' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--ink-3);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.input::placeholder, .textarea::placeholder { color: #b3ada3; }
.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--ink); margin: 0; }

.toggle { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-track { width: 36px; height: 20px; border-radius: 999px; background: var(--line-2); position: relative; transition: background 0.2s; flex: none; }
.toggle-track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform 0.2s var(--ease); }
.toggle input:checked + .toggle-track { background: var(--ink); }
.toggle input:checked + .toggle-track::after { transform: translateX(16px); }
.toggle input:focus-visible + .toggle-track { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 500; white-space: nowrap; background: var(--paper-2); color: var(--ink-2);
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.8; }
.badge-plain::before { display: none; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-accent { background: color-mix(in srgb, var(--accent) 14%, #fff); color: var(--accent); }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 20px; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 1000; display: flex; align-items: flex-start; justify-content: center;
  padding: 8vh 16px 16px; background: rgba(24, 22, 19, 0.42); backdrop-filter: blur(3px);
  animation: fade-in 0.18s var(--ease);
  overflow-y: auto;
}
.modal {
  width: 100%; max-width: 520px; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  animation: rise-in 0.22s var(--ease); display: flex; flex-direction: column; max-height: none;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 0; }
.modal-title { font-family: var(--font-display); font-size: 24px; font-weight: 500; }
.modal-body { padding: 16px 20px 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* ---------- toast ---------- */
.toasts { position: fixed; z-index: 2000; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; max-width: min(92vw, 520px);
  padding: 10px 16px; border-radius: 999px; background: var(--ink); color: #f7f3ec; box-shadow: var(--shadow-lg);
  font-size: 13.5px; animation: rise-in 0.25s var(--ease);
}
.toast.toast-error { background: var(--danger); }
.toast.toast-success svg { color: #9fd3a8; }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: all 0.25s; }

/* ---------- menu ---------- */
.menu-wrap { position: relative; display: inline-flex; }
.menu {
  position: absolute; z-index: 900; top: calc(100% + 6px); right: 0; min-width: 190px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg);
  animation: rise-in 0.14s var(--ease);
}
.menu.menu-left { left: 0; right: auto; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 7px;
  background: none; text-align: left; font-size: 13.5px; cursor: pointer; color: var(--ink); text-decoration: none;
}
.menu-item svg { width: 16px; height: 16px; color: var(--ink-3); }
.menu-item:hover { background: var(--paper); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger svg { color: var(--danger); }
.menu-sep { height: 1px; margin: 6px 4px; background: var(--line); }

/* ---------- misc ---------- */
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid color-mix(in srgb, currentColor 25%, transparent); border-top-color: currentColor; animation: spin 0.7s linear infinite; }
.loading-block { display: grid; place-items: center; padding: 64px 0; color: var(--ink-3); }
.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 56px 24px;
  color: var(--ink-2);
}
.empty-icon { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 50%; background: var(--paper-2); color: var(--ink-3); }
.empty-icon svg { width: 24px; height: 24px; }
.empty h3 { font-family: var(--font-display); font-size: 24px; color: var(--ink); }
.empty p { max-width: 420px; }

.prose { font-size: 15px; line-height: 1.7; color: var(--ink); }
.prose h2 { font-family: var(--font-display); font-size: 28px; margin: 1.2em 0 0.4em; }
.prose h3 { font-family: var(--font-display); font-size: 21px; margin: 1.3em 0 0.3em; }
.prose h4 { font-size: 14px; text-transform: uppercase; letter-spacing: 0.08em; margin: 1.2em 0 0.3em; }
.prose p, .prose ul, .prose ol { margin: 0 0 0.9em; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 1.6em 0; }
.prose > :first-child { margin-top: 0; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes rise-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- standalone error page ---------- */
.error-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.error-card { max-width: 460px; text-align: center; display: flex; flex-direction: column; gap: 14px; }
.error-card h1 { font-family: var(--font-display); font-size: 40px; font-weight: 500; }
.error-card p { color: var(--ink-2); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
