/* === Design tokens — Hancom heritage / Fluent 2 === */
:root {
  /* Surface */
  --bg-canvas: oklch(0.99 0.003 250);
  --bg-surface: oklch(0.98 0.005 250);
  --bg-card: oklch(1 0 0);
  --bg-input: oklch(0.99 0.003 250);

  /* Ink */
  --ink-primary: oklch(0.20 0.02 250);
  --ink-secondary: oklch(0.45 0.02 250);
  --ink-tertiary: oklch(0.65 0.02 250);

  /* Lines */
  --rule-hairline: oklch(0.92 0.005 250);
  --rule-strong: oklch(0.85 0.008 250);

  /* Accent (Hancom-blue) */
  --accent: oklch(0.50 0.16 245);
  --accent-hover: oklch(0.45 0.17 245);
  --accent-pressed: oklch(0.40 0.17 245);
  --on-accent: oklch(0.99 0.003 250);
  --accent-tint: oklch(0.96 0.02 245);

  /* State */
  --state-error: oklch(0.55 0.20 25);
  --state-error-tint: oklch(0.96 0.04 25);

  /* Spacing (4/8/12/16/24/32/48/64) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;

  /* Type */
  --font-sans: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont,
               "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", "IBM Plex Mono", "D2Coding", ui-monospace, monospace;

  /* Motion */
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --duration-fast: 120ms;
  --duration-base: 180ms;

  /* Elevation */
  --shadow-sm: 0 1px 2px oklch(0.20 0.02 250 / 0.06);
  --shadow-md: 0 2px 8px oklch(0.20 0.02 250 / 0.08), 0 1px 2px oklch(0.20 0.02 250 / 0.04);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink-primary);
  background: var(--bg-canvas);
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 980px;
  margin: 0 auto;
  padding: var(--space-5) var(--space-5) var(--space-7);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.app__header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--rule-hairline);
}
.app__mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--accent-tint);
  color: var(--accent);
  font-weight: 700;
}
.app__title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}
.app__subtitle {
  margin-left: auto;
  color: var(--ink-tertiary);
  font-size: 13px;
}

.editor-shell {
  background: var(--bg-card);
  border: 1px solid var(--rule-hairline);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 360px;
}
.editor-shell #editor { flex: 1 1 auto; }

.actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.actions__filename {
  flex: 1 1 240px;
  min-width: 200px;
  height: 36px;
  padding: 0 var(--space-3);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink-primary);
  transition: border-color var(--duration-fast) var(--ease),
              box-shadow var(--duration-fast) var(--ease);
}
.actions__filename:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 36px;
  padding: 0 var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease),
              border-color var(--duration-fast) var(--ease),
              transform var(--duration-fast) var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn--primary {
  background: var(--accent);
  color: var(--on-accent);
}
.btn--primary:hover { background: var(--accent-hover); }
.btn--primary:active { background: var(--accent-pressed); }
.btn--secondary {
  background: var(--bg-card);
  color: var(--ink-primary);
  border-color: var(--rule-strong);
}
.btn--secondary:hover { background: var(--bg-surface); }

.toast {
  margin-top: var(--space-2);
  font-size: 13px;
  color: var(--ink-secondary);
  min-height: 18px;
  transition: opacity var(--duration-fast) var(--ease);
}
.toast--error { color: var(--state-error); }

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

/* === Milkdown Crepe overrides — align with project tokens === */

/* Fill the editor-shell container */
.editor-shell #editor,
.editor-shell .milkdown {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.editor-shell .milkdown-root,
.editor-shell .ProseMirror {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  padding: var(--space-4) var(--space-5);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink-primary);
  outline: none;
}

/* Placeholder */
.editor-shell .ProseMirror .placeholder {
  color: var(--ink-tertiary);
  pointer-events: none;
  position: absolute;
}

/* Milkdown toolbar — align with project tokens */
.editor-shell .milkdown-menu,
.editor-shell .crepe-toolbar {
  border-bottom: 1px solid var(--rule-hairline);
  background: var(--bg-surface);
  padding: var(--space-2) var(--space-3);
}

/* Selection color */
.editor-shell .ProseMirror ::selection {
  background: var(--accent-tint);
}

/* Tables inside editor */
.editor-shell .ProseMirror table {
  border-collapse: collapse;
  width: 100%;
  font-size: 14px;
}
.editor-shell .ProseMirror th,
.editor-shell .ProseMirror td {
  border: 1px solid var(--rule-strong);
  padding: var(--space-2) var(--space-3);
  text-align: left;
}
.editor-shell .ProseMirror th {
  background: var(--bg-surface);
  font-weight: 600;
}

/* Code blocks */
.editor-shell .ProseMirror pre {
  background: var(--bg-surface);
  border: 1px solid var(--rule-hairline);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-mono);
  font-size: 13px;
  overflow-x: auto;
}

/* Inline code */
.editor-shell .ProseMirror code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--bg-surface);
  padding: 1px 5px;
  border-radius: var(--radius-sm);
}

/* Headings */
.editor-shell .ProseMirror h1,
.editor-shell .ProseMirror h2,
.editor-shell .ProseMirror h3 {
  font-weight: 600;
  line-height: 1.3;
  margin-top: var(--space-5);
  margin-bottom: var(--space-2);
  color: var(--ink-primary);
}
.editor-shell .ProseMirror h1 { font-size: 22px; }
.editor-shell .ProseMirror h2 { font-size: 18px; }
.editor-shell .ProseMirror h3 { font-size: 16px; }

/* Paragraphs */
.editor-shell .ProseMirror p {
  margin: 0 0 var(--space-3);
}

/* Blockquote */
.editor-shell .ProseMirror blockquote {
  border-left: 3px solid var(--accent);
  margin: 0;
  padding-left: var(--space-4);
  color: var(--ink-secondary);
}
