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

:root {
  --radius: 16px;
  --radius-sm: 8px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 16px;
  --space-4: 24px;
  --space-5: 32px;
  --space-6: 48px;
  --transition: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  
  /* Premium Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.05), 0 12px 28px rgba(0,0,0,0.06);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.08), 0 24px 56px rgba(0,0,0,0.1);
  --shadow-gold: 0 4px 12px rgba(181, 152, 90, 0.2), 0 12px 24px rgba(181, 152, 90, 0.15);
}

html[data-theme="light"] {
  --bg: #F5EFE3;
  --surface: #FFFBF3;
  --surface-2: #EDE3D2;
  --border: #E0D2BC;
  --text: #1C1420;
  --text-muted: #6E5E68;
  --accent: #2C8C86;
  --accent-hover: #216B66;
  --accent-glow: #3FB5AD;
  --accent-ink: #FFFBF3;
  --gold: #B5985A;
  --gold-hover: #A08A4E;
  --gold-gloss: linear-gradient(180deg, #D4AF37 0%, #B5985A 100%);
  --glass-bg: rgba(255, 251, 243, 0.6);
  --glass-border: rgba(255, 255, 255, 0.5);
}

html[data-theme="dark"] {
  --bg: #0B1120;
  --surface: #121A2E;
  --surface-2: #1A2540;
  --border: #26314F;
  --text: #ECEFF6;
  --text-muted: #8A97B4;
  --accent: #3FB5AD;
  --accent-hover: #5AD6CD;
  --accent-glow: #66E0D6;
  --accent-ink: #0B1120;
  --gold: #D4AF37;
  --gold-hover: #E2C04A;
  --gold-gloss: linear-gradient(180deg, #F0CE6A 0%, #D4AF37 100%);
  --glass-bg: rgba(26, 37, 64, 0.5);
  --glass-border: rgba(255, 255, 255, 0.05);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--transition), color var(--transition);
}

h1, h2, h3, h4 { font-family: 'Fraunces', serif; font-weight: 600; line-height: 1.2; letter-spacing: -0.02em; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

.wrap { max-width: 1440px; margin: 0 auto; padding: 0 var(--space-4); }

/* Header */
.app-header {
  position: sticky; top: 0; z-index: 100;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border);
}
.app-header .wrap { display: flex; align-items: center; justify-content: space-between; height: 68px; }
.brand { font-family: 'Fraunces', serif; font-size: 26px; font-weight: 600; color: var(--text); text-decoration: none; display: flex; align-items: center; gap: 12px; letter-spacing: -0.03em; }
.brand-dot { width: 12px; height: 12px; background: var(--gold-gloss); border-radius: 3px; transform: rotate(45deg); box-shadow: var(--shadow-gold); }
.header-right { display: flex; align-items: center; gap: var(--space-4); }

/* Navigation */
.main-nav { display: flex; gap: 4px; align-items: center; background: var(--surface); padding: 4px; border-radius: 100px; border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.nav-link { padding: 8px 16px; font-size: 13px; font-weight: 500; color: var(--text-muted); border-radius: 100px; text-decoration: none; transition: all var(--transition); }
.nav-link:hover { color: var(--text); }
.nav-link.active { color: var(--text); background: var(--surface-2); box-shadow: var(--shadow-sm); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 24px; border-radius: 100px; border: 1px solid transparent; background: var(--accent); color: var(--accent-ink); font-size: 14px; font-weight: 600; transition: all var(--transition); text-decoration: none; width: 100%; box-shadow: var(--shadow-sm); }
.btn:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0); box-shadow: var(--shadow-sm); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--text-muted); }
.btn-gold { background: var(--gold-gloss); color: #1C1420; border: 1px solid var(--gold-hover); box-shadow: var(--shadow-gold); }
.btn-gold:hover { background: var(--gold-gloss); filter: brightness(1.1); }
.btn-sm { padding: 8px 16px; font-size: 13px; width: auto; }

/* Theme Toggle */
.theme-toggle { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--text); display: flex; align-items: center; justify-content: center; transition: all var(--transition); box-shadow: var(--shadow-sm); }
.theme-toggle:hover { background: var(--surface-2); border-color: var(--gold); color: var(--gold); transform: rotate(15deg); }
.theme-toggle svg { width: 18px; height: 18px; }
html[data-theme="light"] .icon-moon { display: none; }
html[data-theme="dark"] .icon-sun { display: none; }

/* Badges & Chips */
.badge { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; padding: 6px 12px; border-radius: 100px; background: var(--gold-gloss); color: #1C1420; border: 1px solid var(--gold-hover); box-shadow: var(--shadow-sm); }
.chip { display: inline-flex; align-items: center; gap: 4px; font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--text-muted); background: var(--surface-2); padding: 6px 10px; border-radius: 6px; border: 1px solid var(--border); }
.qcode { font-family: 'JetBrains Mono', monospace; font-size: 12px; font-weight: 500; color: var(--gold); background: color-mix(in srgb, var(--gold) 10%, transparent); padding: 6px 10px; border-radius: 6px; letter-spacing: 0.5px; border: 1px solid color-mix(in srgb, var(--gold) 20%, transparent); }

/* Difficulty Pellets */
.diff { display: inline-flex; gap: 4px; align-items: center; }
.diff span { width: 12px; height: 12px; border-radius: 3px; background: var(--border); transition: background var(--transition); }
.diff span.on { background: var(--gold-gloss); box-shadow: 0 0 8px color-mix(in srgb, var(--gold) 40%, transparent); }

/* Forms */
.input, .select, .textarea { width: 100%; padding: 12px 16px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-family: inherit; font-size: 14px; transition: all var(--transition); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 4px color-mix(in srgb, var(--gold) 15%, transparent); }

/* Custom Premium Checkboxes */
.checkbox-group label { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--text); cursor: pointer; padding: 8px 0; user-select: none; transition: color var(--transition); }
.checkbox-group label:hover { color: var(--gold); }
.checkbox-group input[type="checkbox"] { position: absolute; opacity: 0; width: 0; height: 0; }
.cb-box { 
  width: 22px; height: 22px; 
  background: var(--bg); 
  border: 1.5px solid var(--border); 
  border-radius: 7px; 
  display: flex; align-items: center; justify-content: center; 
  transition: all var(--transition); 
  flex-shrink: 0; 
}
.cb-box svg { 
  width: 14px; height: 14px; 
  color: #1C1420; 
  opacity: 0; 
  transform: scale(0.5); 
  transition: all var(--transition); 
  stroke-linecap: round; 
  stroke-linejoin: round; 
}
.checkbox-group input[type="checkbox"]:checked ~ .cb-box { 
  background: var(--gold-gloss); 
  border-color: var(--gold-hover); 
  box-shadow: 0 2px 8px rgba(181, 152, 90, 0.3); 
}
.checkbox-group input[type="checkbox"]:checked ~ .cb-box svg { 
  opacity: 1; transform: scale(1); 
}

/* Empty State */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: var(--space-6); color: var(--text-muted); }
.empty-state h3 { margin-bottom: var(--space-2); color: var(--text); }

/* Glass Panels (Premium Cards) */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}

/* Accessibility / Focus */
:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Premium Custom Scrollbars - Navy Track with Gold Thumb */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--gold) #0B1120; /* Navy track, Gold thumb (Firefox) */
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: #0B1120; /* Midnight Navy */
  border-radius: 100px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

*::-webkit-scrollbar-thumb {
  background: var(--gold-gloss);
  border-radius: 100px;
  border: 2px solid #0B1120; /* Navy outline */
  box-shadow: 0 0 8px rgba(181, 152, 90, 0.4);
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--gold-hover);
  border: 2px solid #0B1120;
}

/* Light mode tweak for better visibility */
html[data-theme="light"] *::-webkit-scrollbar-track {
  background: #EDE3D2; 
}
html[data-theme="light"] *::-webkit-scrollbar-thumb {
  border-color: #EDE3D2;
}

/* Collapsibles */
.collapse-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
  padding: 12px 0;
}
.collapse-arrow {
  transition: transform 0.2s ease;
  color: var(--text-muted);
}
.collapse-header.collapsed .collapse-arrow {
  transform: rotate(-90deg);
}
.collapse-content {
  max-height: 1000px;
  overflow: hidden;
  transition: max-height 0.3s ease-in-out;
}
.collapse-content.collapsed {
  max-height: 0;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}

/* Editable Paper Inputs */
.paper-input {
  background: rgba(181, 152, 90, 0.05);
  border: 1px dashed rgba(181, 152, 90, 0.4);
  border-radius: 4px;
  padding: 4px 8px;
  transition: all 0.2s;
}
.paper-input:hover {
  border-style: solid;
  border-color: var(--gold);
}
.paper-input:focus {
  outline: none;
  background: #FFF;
  border: 1px solid var(--gold);
  box-shadow: 0 0 0 2px rgba(181, 152, 90, 0.2);
}

/* Resizable Panels */
.resizable-panel {
  resize: horizontal;
  overflow: auto;
  min-width: 320px;
  max-width: 600px;
}
.resizable-panel::-webkit-scrollbar {
  height: 8px;
  width: 8px;
}

/* Print Footer */
@media print {
  .paper::after {
    content: "dulus.com";
    position: fixed;
    bottom: 10mm;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 10pt;
    color: #8A97B4;
    font-family: 'Inter', sans-serif;
  }
}