/* ============================================================================
   STUDIO OS · DESIGN SYSTEM
   Editorial Photography Style — Jennifer Daschner inspired
   ============================================================================ */

:root {
  /* --- Colors · Warm editorial palette --- */
  --bg:          #faf8f5;   /* warm cream */
  --bg-alt:      #f3efe9;
  --bg-elev:    #ffffff;
  --ink:         #1a1a1a;   /* near-black for text */
  --ink-soft:    #3d3d3d;
  --ink-muted:   #8a8580;   /* warm gray */
  --ink-faint:   #c5c0b8;
  --line:        #e8e3db;   /* hairline separator */
  --line-soft:   #f0ece5;
  --accent:      #1a1a1a;   /* monochrome accent */
  --accent-soft: #2a2a2a;

  /* Status */
  --success:     #3d6b4f;
  --success-bg:  #e8f0ea;
  --warn:        #a36a15;
  --warn-bg:     #faf0dd;
  --danger:      #8f2f2f;
  --danger-bg:   #f6e4e4;
  --info:        #3a5a7e;
  --info-bg:     #e6ecf2;

  /* --- Typography --- */
  --font-serif:  'Cormorant Garamond', 'EB Garamond', Georgia, 'Times New Roman', serif;
  --font-sans:   'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --font-mono:   'JetBrains Mono', 'SF Mono', 'Monaco', 'Courier New', monospace;

  /* Type scale · editorial hierarchy */
  --h1-size: clamp(2.75rem, 6vw, 5.5rem);
  --h2-size: clamp(2rem, 4vw, 3.25rem);
  --h3-size: clamp(1.5rem, 2.5vw, 2rem);
  --h4-size: 1.25rem;
  --body-size: 0.9375rem;
  --small-size: 0.8125rem;
  --eyebrow-size: 0.6875rem;

  /* Spacing · generous for editorial feel */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.5rem;
  --sp-6: 2rem;
  --sp-7: 3rem;
  --sp-8: 4rem;
  --sp-9: 6rem;

  /* Layout */
  --max-content: 1440px;
  --sidebar-w: 240px;
  --topbar-h: 72px;

  /* Effects */
  --radius-sm: 2px;
  --radius: 4px;
  --radius-lg: 8px;
  --shadow-sm: 0 1px 2px rgba(26, 26, 26, 0.04);
  --shadow: 0 4px 20px rgba(26, 26, 26, 0.06);
  --shadow-lg: 0 12px 40px rgba(26, 26, 26, 0.08);

  /* Motion */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.2, 0, 0, 1);
  --dur-fast: 160ms;
  --dur: 240ms;
  --dur-slow: 480ms;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--body-size);
  line-height: 1.6;
  font-feature-settings: 'kern', 'liga', 'clig', 'calt';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}
img, svg { max-width: 100%; display: block; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* --- Typography --- */
h1, h2, h3, h4 {
  font-family: var(--font-serif);
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--ink);
}
h1 { font-size: var(--h1-size); letter-spacing: -0.025em; }
h2 { font-size: var(--h2-size); letter-spacing: -0.02em; }
h3 { font-size: var(--h3-size); }
h4 { font-size: var(--h4-size); font-family: var(--font-sans); font-weight: 500; letter-spacing: 0.02em; }

.eyebrow {
  font-family: var(--font-sans);
  font-size: var(--eyebrow-size);
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-muted);
  line-height: 1;
}
.muted { color: var(--ink-muted); }
.small { font-size: var(--small-size); }
.mono { font-family: var(--font-mono); font-size: 0.85em; }

/* --- Utility --- */
.container {
  max-width: var(--max-content);
  margin: 0 auto;
  padding: 0 var(--sp-6);
}
@media (max-width: 640px) {
  .container { padding: 0 var(--sp-4); }
}
.stack > * + * { margin-top: var(--sp-4); }
.stack-lg > * + * { margin-top: var(--sp-6); }
.row { display: flex; gap: var(--sp-4); align-items: center; flex-wrap: wrap; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-4); flex-wrap: wrap; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hairline { height: 1px; background: var(--line); border: 0; margin: 0; }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 0.625rem 1.25rem;
  font-size: var(--small-size);
  font-weight: 500;
  letter-spacing: 0.04em;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--bg);
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
  border-radius: var(--radius-sm);
  text-transform: uppercase;
}
.btn:hover { background: var(--accent-soft); text-decoration: none; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-ghost {
  background: transparent;
  color: var(--ink);
}
.btn-ghost:hover { background: var(--bg-alt); }
.btn-sm { padding: 0.375rem 0.875rem; font-size: 0.75rem; }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: #6f2424; }

/* Icon button */
.icon-btn {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius);
  color: var(--ink-soft);
  transition: background var(--dur) var(--ease);
}
.icon-btn:hover { background: var(--bg-alt); }

/* --- Form elements --- */
.field { display: flex; flex-direction: column; gap: var(--sp-2); }
.field label {
  font-size: var(--eyebrow-size);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 500;
}
.input, .select, .textarea {
  width: 100%;
  padding: 0.625rem 0.875rem;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  font-size: var(--body-size);
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--ink);
  background: var(--bg-elev);
}
.textarea { min-height: 100px; resize: vertical; font-family: inherit; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238a8580' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--sp-4);
}
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }
@media (max-width: 640px) { .form-row-2 { grid-template-columns: 1fr; } }

/* --- Card --- */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--sp-6);
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.card-hover:hover {
  border-color: var(--ink-faint);
  transform: translateY(-1px);
}
.card-flat {
  background: transparent;
  border: 1px solid var(--line);
  padding: var(--sp-5);
  border-radius: var(--radius);
}

/* --- Badge --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.25rem 0.625rem;
  border-radius: 999px;
  background: var(--bg-alt);
  color: var(--ink-soft);
  line-height: 1.5;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
  display: inline-block;
}

/* --- Table --- */
.table {
  width: 100%;
  border-collapse: collapse;
}
.table th, .table td {
  text-align: left;
  padding: var(--sp-4) var(--sp-4);
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.table th {
  font-size: var(--eyebrow-size);
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-muted);
  white-space: nowrap;
}
.table tbody tr { transition: background var(--dur-fast) var(--ease); cursor: pointer; }
.table tbody tr:hover { background: var(--bg-alt); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* --- Toast --- */
.toast-layer {
  position: fixed;
  top: var(--sp-5); right: var(--sp-5);
  z-index: 1000;
  display: flex; flex-direction: column; gap: var(--sp-3);
  pointer-events: none;
}
.toast {
  background: var(--ink);
  color: var(--bg);
  padding: var(--sp-4) var(--sp-5);
  border-radius: var(--radius);
  font-size: var(--small-size);
  max-width: 360px;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toast-in var(--dur) var(--ease-out);
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }
@keyframes toast-in {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* --- Spinner --- */
.spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--line);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.spinner-lg { width: 28px; height: 28px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Loading / Empty --- */
.loading-state, .empty-state {
  padding: var(--sp-8) var(--sp-5);
  text-align: center;
  color: var(--ink-muted);
}
.empty-state h3 { font-family: var(--font-serif); font-size: 1.75rem; margin-bottom: var(--sp-3); color: var(--ink); }
.empty-state p { max-width: 40ch; margin: 0 auto; }

/* --- Modal --- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(26, 26, 26, 0.45);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  z-index: 900;
  padding: var(--sp-4);
  animation: fade-in var(--dur) var(--ease);
}
@keyframes fade-in { from { opacity: 0 } to { opacity: 1 } }
.modal {
  background: var(--bg);
  border-radius: var(--radius-lg);
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
  box-shadow: var(--shadow-lg);
  animation: modal-in var(--dur-slow) var(--ease-out);
}
@keyframes modal-in {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.modal-lg { max-width: 900px; }
.modal-head {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: var(--sp-6) var(--sp-6) var(--sp-4);
  border-bottom: 1px solid var(--line);
}
.modal-head h2 { font-size: 1.75rem; }
.modal-body { padding: var(--sp-6); }
.modal-foot {
  padding: var(--sp-4) var(--sp-6) var(--sp-6);
  display: flex; justify-content: flex-end; gap: var(--sp-3);
  border-top: 1px solid var(--line);
}

/* Utility scroll */
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
