:root {
  --primary: #ffce2b;
  --primary-strong: #f2b800;
  --primary-soft: #ffe799;
  --bg-main: #fffdf7;
  --bg-accent: #fff3c2;
  --ink-main: #1d1b17;
  --ink-muted: #6a5f38;
  --line: #e8d17b;
  /* --panel: #fffdf9; */
  --panel: #fff;
  /* --editor-bg: #fff8de; */
  --editor-bg: white;
  --code-bg: #fff3c8;
  --shadow: 0 14px 35px rgba(102, 72, 24, 0.15);
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--ink-main);
  /* background: #ffce2b; */
  /* background:
    radial-gradient(
      circle at 0% 0%,
      color-mix(in srgb, var(--primary) 85%, white 15%),
      transparent 50%
    ),
    radial-gradient(
      circle at 92% 100%,
      color-mix(in srgb, var(--primary) 40%, #111 60%),
      transparent 50%
    ),
    linear-gradient(130deg, var(--bg-main), var(--bg-accent)); */
  padding: 2rem;
}

.app {
  max-width: 96%;
  margin: 0 auto;
  background: color-mix(in srgb, white 92%, var(--primary) 8%);
  border: 1px solid color-mix(in srgb, var(--primary) 55%, #b08b00 45%);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(4px);
  overflow: hidden;
  animation: fade-up 420ms ease-out both;
}

.header {
  padding: 1.3rem 1.5rem;
  border-bottom: 1px solid var(--line);
  background: #444;
  color: white;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.title {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(1.2rem, 2.2vw, 1.8rem);
  letter-spacing: 0.01em;
}

.subtitle {
  margin: 0.3rem 0 0;
  color: white;
  font-size: 0.95rem;
}

.actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

button {
  border: 1px solid color-mix(in srgb, var(--primary) 65%, #8b6b00 35%);
  /* background: color-mix(in srgb, var(--primary) 40%, white 60%); */
  color: #2e2300;
  background: #ffce2b;
  border-radius: 999px;
  padding: 0.55rem 0.95rem;
  font:
    500 0.88rem/1 "IBM Plex Mono",
    monospace;
  cursor: pointer;
  transition:
    transform 150ms ease,
    box-shadow 150ms ease,
    background-color 150ms ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(121, 91, 42, 0.18);
  background: color-mix(in srgb, var(--primary) 58%, white 42%);
}

.panes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 65vh;
}

.pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.pane + .pane {
  border-left: 1px solid var(--line);
}

.pane-head {
  margin: 0;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--line);
  font:
    700 0.82rem/1.4 "IBM Plex Mono",
    monospace;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #3e3000;
  background: color-mix(in srgb, var(--primary) 100%, white 50%);
}

#editor {
  flex: 1;
  width: 100%;
  border: 0;
  margin: 0;
  padding: 1rem;
  resize: none;
  /* background: var(--editor-bg); */
  /* background: #eee;
  color: #1f1800; */
  background: #333;
  color: white;
  font:
    400 0.95rem/1.6 "IBM Plex Mono",
    monospace;
  caret-color: var(--primary-strong);
  outline: none;
}

#preview {
  flex: 1;
  margin: 0;
  overflow: auto;
  padding: 1rem 1.2rem;
  background: var(--panel);
  line-height: 1.7;
  animation: fade-in 250ms ease-out;
}

#preview h1,
#preview h2,
#preview h3 {
  font-family: "Fraunces", Georgia, serif;
  line-height: 1.2;
  margin-top: 1.3em;
  margin-bottom: 0.5em;
}

#preview h1 {
  font-size: 1.7rem;
}

#preview h2 {
  font-size: 1.35rem;
}

#preview h3 {
  font-size: 1.1rem;
}

#preview p,
#preview ul,
#preview ol,
#preview blockquote {
  margin-top: 0.7em;
  margin-bottom: 0.7em;
}

#preview blockquote {
  border-left: 4px solid var(--primary);
  padding-left: 0.8rem;
  color: #5f4f2b;
  background: color-mix(in srgb, var(--primary) 24%, white 76%);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

#preview code {
  font-family: "IBM Plex Mono", monospace;
  background: var(--code-bg);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  border: 1px solid color-mix(in srgb, var(--primary) 38%, #d4c08a 62%);
  font-size: 0.9em;
}

#preview pre {
  background: color-mix(in srgb, var(--primary) 18%, white 82%);
  border: 1px solid color-mix(in srgb, var(--primary) 40%, #d4be80 60%);
  border-radius: var(--radius-md);
  padding: 0.9rem;
  overflow: auto;
}

#preview pre code {
  border: 0;
  background: transparent;
  padding: 0;
}

#preview table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.8rem 0;
}

#preview th,
#preview td {
  border: 1px solid color-mix(in srgb, var(--primary) 35%, #d6c08a 65%);
  text-align: left;
  padding: 0.45rem 0.55rem;
}

#preview th {
  background: color-mix(in srgb, var(--primary) 28%, white 72%);
}

#preview .katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.2rem 0;
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fade-in {
  from {
    opacity: 0.6;
  }
  to {
    opacity: 1;
  }
}

@media (max-width: 860px) {
  body {
    padding: 1rem;
  }

  .panes {
    grid-template-columns: 1fr;
  }

  .pane + .pane {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .header {
    padding: 1rem;
  }

  #editor,
  #preview {
    min-height: 42vh;
  }
}
