/* Base design tokens and global resets */
:root {
  /* Core palette */
  --bg: #0b1117;
  --panel: #111922;
  --muted: #1b2530;
  --text: #e6edf3;
  --subtext: #9fb0c0;
  --accent: #10b981;
  --accent2: #059669;
  --btn-accent-text: #ffffff;
  --danger: #ff6b6b;
  --danger2: #e24a4a;
  --btn-danger-text: #ffffff;
  --warn: #ffd166;
  --ok: #8ecae6;
  --card: #0f141a;
  --shadow: 0 6px 20px rgba(0, 0, 0, 0.25);

  /* Semantic surfaces */
  --surface: var(--panel);
  --surface-raised: var(--card);
  --border-strong: rgba(255, 255, 255, 0.12);

  /* Typography scale */
  --font-xs: 0.75rem;
  --font-sm: 0.875rem;
  --font-md: 1rem;
  --font-lg: 1.25rem;
  --font-xl: 1.5rem;

  /* Spacing scale */
  --space-0: 0;
  --space-1: 0.25rem;
  --space-1-5: 0.375rem;
  --space-2: 0.5rem;
  --space-2-5: 0.625rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
}

.theme-light:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --muted: #e9eef3;
  --text: #0c1116;
  --subtext: #4a5a6a;
  --danger: #d83a3a;
  --danger2: #b92424;
  --btn-danger-text: #ffffff;
  --ok: #0ea5e9;
  --card: #ffffff;
  --shadow: 0 10px 24px rgba(7, 14, 22, 0.08);
  --surface: var(--panel);
  --surface-raised: #f3f6fb;
  --border-strong: rgba(12, 17, 22, 0.12);
}

.color-emerald:root {
  --accent: #10b981;
  --accent2: #059669;
}

.color-sky:root {
  --accent: #0ea5e9;
  --accent2: #0284c7;
}

.color-rose:root {
  --accent: #f472b6;
  --accent2: #ec4899;
}

.color-amber:root {
  --accent: #f59e0b;
  --accent2: #d97706;
}

.color-violet:root {
  --accent: #a78bfa;
  --accent2: #7c3aed;
}

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

html,
body {
  height: 100%;
  overflow-x: hidden;
}

body {
  margin: var(--space-0);
  font-family:
    ui-sans-serif,
    system-ui,
    -apple-system,
    Segoe UI,
    Roboto,
    Helvetica,
    Arial,
    'Apple Color Emoji',
    'Segoe UI Emoji';
  font-size: var(--font-md);
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.icon {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 1.5;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.page-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: var(--space-4);
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 28px;
  line-height: 1;
  font-weight: 600;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.page-icon::after {
  content: attr(data-placeholder);
  color: var(--subtext);
  font-size: 20px;
  font-weight: 500;
}

.page-icon[data-empty='0']::after {
  content: none;
}

.page-icon[data-empty='1'] {
  border-style: dashed;
}

.page-icon[contenteditable='true'] {
  cursor: text;
}

.page-icon[contenteditable='true']:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  background: var(--surface);
}

.page-icon[contenteditable='true']:hover {
  border-color: var(--accent);
}

.page-icon--image {
  border-style: solid;
}

.page-icon--image::after {
  content: none;
}

.page-icon--image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

body.is-editing .page-icon--image {
  background: var(--surface);
}

body:not(.is-editing) .page-icon--image {
  border-color: transparent;
  background: transparent;
}

.theme-light body:not(.is-editing) .page-icon--image {
  border-color: transparent;
  background: transparent;
}

.theme-light .page-icon {
  border-color: rgba(12, 17, 22, 0.18);
  background: rgba(12, 17, 22, 0.06);
}

.theme-light .page-icon[contenteditable='true']:focus {
  background: rgba(12, 17, 22, 0.08);
}

kbd {
  font-family: inherit;
  font-size: 0.85em;
  line-height: 1.4;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.75em;
  padding: 0 var(--space-1);
  border-radius: var(--space-1);
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.25);
  text-transform: uppercase;
}

.theme-light kbd {
  border-color: rgba(12, 17, 22, 0.18);
  background: rgba(12, 17, 22, 0.08);
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.35);
}
