@import url("https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=JetBrains+Mono:ital,wght@0,400;0,500;0,600;1,400&display=swap");

:root {
  --font-sans: "DM Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI",
    Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco,
    Consolas, "Liberation Mono", "Courier New", monospace;

  --bg-deep: #05070c;
  --bg: #0a0e16;
  --surface: rgba(18, 24, 38, 0.72);
  --surface-2: rgba(12, 17, 28, 0.85);
  --elevated: rgba(22, 30, 46, 0.94);
  --text: #eef2f8;
  --text-soft: rgba(238, 242, 248, 0.88);
  --muted: #8b9bb0;
  --muted-2: #6b7c94;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);

  --accent: #5ee1ff;
  --accent-dim: rgba(94, 225, 255, 0.14);
  --accent-2: #9effd9;
  --danger: #ff7b9c;
  --danger-bg: rgba(255, 123, 156, 0.1);
  --danger-line: rgba(255, 123, 156, 0.28);

  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 0 1px rgba(94, 225, 255, 0.12),
    0 20px 50px rgba(0, 0, 0, 0.55);

  /* Calibrated pixels-per-centimeter for on-screen preview only. */
  --ppcm: 26;
  --snippet-font-px: 14px;
}

@media (max-width: 700px) {
  :root {
    --snippet-font-px: 13px;
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  color-scheme: dark;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  .menuCard:hover {
    transform: none;
  }
  .brand:hover {
    transform: none;
  }
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  font-optical-sizing: auto;
  color: var(--text);
  background-color: var(--bg-deep);
  background-image:
    radial-gradient(
      ellipse 900px 500px at 15% -10%,
      rgba(94, 225, 255, 0.12),
      transparent 55%
    ),
    radial-gradient(
      ellipse 700px 450px at 95% 15%,
      rgba(158, 255, 217, 0.08),
      transparent 50%
    ),
    radial-gradient(
      ellipse 80% 50% at 50% 100%,
      rgba(99, 102, 241, 0.06),
      transparent 55%
    ),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

.mono {
  font-family: var(--font-mono);
}

.app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px 20px 32px;
  min-height: 100%;
}

/* ——— Top bar ——— */
.topbar {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(12px);
}

.topbar__left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1 1 auto;
}

.brand {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-decoration: none;
  color: var(--bg-deep);
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  box-shadow: 0 4px 16px rgba(94, 225, 255, 0.25);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.brand:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(94, 225, 255, 0.35);
}

.topbar__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-soft);
  line-height: 1.25;
  min-width: 0;
}

.topbar__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.topbar__nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  max-width: 100%;
}

.topbar__nav--scroll {
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.topbar__nav--scroll::-webkit-scrollbar {
  height: 4px;
}

.topbar__nav--scroll::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 4px;
}

.topbar__meta {
  font-size: 12px;
  color: var(--muted);
  font-family: var(--font-mono);
}

/* ——— Layout ——— */
.main {
  display: grid;
  grid-template-columns: 1fr minmax(280px, 380px);
  gap: 16px;
  margin-top: 16px;
  align-items: start;
}

.main--single {
  grid-template-columns: 1fr;
}

.main--split {
  grid-template-columns: 1fr minmax(280px, 380px);
}

.main--even {
  grid-template-columns: 1fr 1fr;
}

@media (max-width: 980px) {
  .main,
  .main--split,
  .main--even {
    grid-template-columns: 1fr;
  }
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  padding: 18px;
  min-height: 520px;
  box-shadow: var(--shadow-sm);
}

.panel--right {
  background: linear-gradient(
    165deg,
    rgba(22, 30, 46, 0.95) 0%,
    rgba(14, 19, 30, 0.92) 100%
  );
}

.panel__title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 14px;
}

.panel__footer {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.panel__footer-extras {
  margin-top: 10px;
}

/* ——— Buttons ——— */
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
  font-family: inherit;
  font-weight: 600;
  font-size: 13px;
  text-decoration: none;
  line-height: 1.2;
  white-space: nowrap;
  transition:
    transform 0.08s ease,
    background 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--line-strong);
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn--primary {
  border-color: rgba(94, 225, 255, 0.45);
  background: linear-gradient(
    180deg,
    rgba(94, 225, 255, 0.22) 0%,
    rgba(94, 225, 255, 0.1) 100%
  );
  box-shadow: 0 0 20px rgba(94, 225, 255, 0.08);
}

.btn--primary:hover {
  border-color: rgba(94, 225, 255, 0.6);
  background: linear-gradient(
    180deg,
    rgba(94, 225, 255, 0.3) 0%,
    rgba(94, 225, 255, 0.14) 100%
  );
}

.btn--small {
  padding: 7px 11px;
  font-size: 12px;
}

.btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.btn--ghost:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

/* ——— Landing ——— */
.landing__hero {
  padding: 8px 0 28px;
  max-width: 640px;
}

.landing__eyebrow {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}

.landing__headline {
  margin: 0 0 12px;
  font-size: clamp(1.75rem, 4vw, 2.35rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  background: linear-gradient(120deg, var(--text) 0%, var(--muted) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.landing__sub {
  margin: 0;
  font-size: 15px;
  color: var(--muted);
  line-height: 1.55;
}

.menuGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.menuCard {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  background: linear-gradient(
    165deg,
    rgba(22, 30, 46, 0.55) 0%,
    rgba(12, 17, 28, 0.75) 100%
  );
  transition:
    transform 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease;
}

.menuCard:hover {
  transform: translateY(-3px);
  border-color: rgba(94, 225, 255, 0.22);
  box-shadow: var(--shadow-glow);
}

.menuCard__icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  background: var(--accent-dim);
  border: 1px solid rgba(94, 225, 255, 0.2);
  color: var(--accent);
}

.menuCard__icon svg {
  width: 22px;
  height: 22px;
}

.menuCard__tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-2);
  margin-bottom: 6px;
}

.menuCard__title {
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
  color: var(--text-soft);
}

.menuCard__desc {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  flex: 1 1 auto;
  margin-bottom: 16px;
}

.menuCard__actions {
  margin-top: auto;
}

.menuCard__actions .btn {
  width: 100%;
}

.empty {
  border: 1px dashed rgba(255, 255, 255, 0.16);
  border-radius: var(--radius-lg);
  padding: 28px 22px;
  background: rgba(0, 0, 0, 0.2);
  text-align: center;
  margin-top: 14px;
}

.empty__title {
  font-weight: 600;
  font-size: 15px;
}

.empty__hint {
  color: var(--muted);
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.45;
}

.hidden {
  display: none !important;
}

.review__nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.review__counter {
  color: var(--muted);
  font-size: 13px;
  font-family: var(--font-mono);
}

.controls {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 14px;
  background: rgba(0, 0, 0, 0.22);
}

.controls__row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.controls__row--meta {
  margin-top: 12px;
}

.control {
  flex: 1 1 260px;
  min-width: 220px;
}

.control--compact {
  flex: 0 0 auto;
  min-width: 160px;
}

.control__label {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 8px;
}

.control__inline {
  display: flex;
  align-items: center;
  gap: 10px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.meta {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}

.meta__k {
  color: var(--text-soft);
  opacity: 0.9;
  margin-right: 6px;
  font-weight: 500;
}

.stage {
  margin-top: 12px;
  padding: 14px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.18);
}

.stage__cal {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.cal__left {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.cal__label {
  font-size: 12px;
  color: var(--muted);
}

.cal__value {
  font-family: var(--font-mono);
  color: var(--text-soft);
  font-size: 12px;
}

.cal__ruler {
  position: relative;
  height: 16px;
  width: calc(10 * var(--ppcm) * 1px);
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: linear-gradient(
    90deg,
    rgba(94, 225, 255, 0.15),
    rgba(158, 255, 217, 0.1)
  );
  overflow: hidden;
}

.cal__ruler:before {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to right,
    rgba(255, 255, 255, 0.35) 0px,
    rgba(255, 255, 255, 0.35) 1px,
    transparent 1px,
    transparent calc(var(--ppcm) * 1px)
  );
  opacity: 0.35;
  pointer-events: none;
}

.cal__rulerText {
  font-size: 12px;
  color: var(--muted);
}

.cal__slider {
  width: 190px;
}

.stage__frame {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.frame__label {
  font-size: 12px;
  color: var(--muted);
}

.frame {
  width: calc(18 * var(--ppcm) * 1px);
  height: calc(27 * var(--ppcm) * 1px);
  max-width: 100%;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.06),
    rgba(255, 255, 255, 0.02)
  );
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}

.frame:before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to right, rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: calc(var(--ppcm) * 1px) calc(var(--ppcm) * 1px);
  opacity: 0.4;
  pointer-events: none;
}

.frame img {
  position: relative;
  image-rendering: auto;
  box-shadow: var(--shadow);
  border-radius: 8px;
}

.settings {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.setting__label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.setting input,
.setting select {
  width: 150px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--line);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
}

.setting input:focus,
.setting select:focus {
  outline: none;
  border-color: rgba(94, 225, 255, 0.45);
  box-shadow: 0 0 0 3px rgba(94, 225, 255, 0.12);
}

.status {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.calInfo {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(0, 0, 0, 0.18);
  padding: 14px;
}

.calInfo__line {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.calInfo__line + .calInfo__line {
  margin-top: 8px;
}

.calStage {
  margin-top: 14px;
  padding: 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.2);
  overflow: auto;
}

.a4Outline {
  border-radius: var(--radius-sm);
  border: 2px solid rgba(255, 255, 255, 0.28);
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.06),
    rgba(255, 255, 255, 0.02)
  );
  box-shadow: var(--shadow);
}

/* ——— Shared diagram / code tools ——— */
.toolToolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
}

.toolField {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.toolField .setting__label {
  margin: 0;
  white-space: nowrap;
}

.toolField input,
.toolField select {
  width: 160px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--line);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
}

.toolField input:focus,
.toolField select:focus {
  outline: none;
  border-color: rgba(94, 225, 255, 0.45);
}

.toolField--narrow input {
  width: 88px;
  font-family: var(--font-mono);
}

.toolLayout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

@media (max-width: 980px) {
  .toolLayout {
    grid-template-columns: 1fr;
  }
}

.toolEditor {
  min-height: 520px;
  width: 100%;
  resize: vertical;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 14px;
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.45;
}

.toolEditor:focus {
  outline: none;
  border-color: rgba(94, 225, 255, 0.4);
  box-shadow: 0 0 0 3px rgba(94, 225, 255, 0.1);
}

.toolPreview {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 520px;
  background: rgba(0, 0, 0, 0.22);
  overflow: auto;
}

.toolPreview svg {
  display: block;
  margin: 0 auto;
  max-width: none;
}

.toolPreview img {
  display: block;
  margin: 0 auto;
  max-width: none;
}

.statusDetails {
  margin-top: 10px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-soft);
  background: var(--danger-bg);
  border: 1px solid var(--danger-line);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  max-height: 220px;
  overflow: auto;
}

.errorBox {
  padding: 18px;
  color: var(--text-soft);
}

.errorBox__title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 10px;
  color: var(--danger);
}

.errorBox__pre {
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--danger-bg);
  border: 1px solid var(--danger-line);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin: 0;
  max-height: 520px;
  overflow: auto;
}

/* ——— Code snippet maker (light canvas inside dark chrome) ——— */
.snippetToolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  align-items: flex-end;
}

.snippetField {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.snippetField .snippetLabel {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}

.snippetField input {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  width: 140px;
}

.snippetField input:focus {
  outline: none;
  border-color: rgba(94, 225, 255, 0.45);
}

.snippetEditor {
  width: 100%;
  min-height: 520px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  font-family: var(--font-mono);
  font-size: var(--snippet-font-px, 14px);
  line-height: 1.45;
  color: #0a0a0a;
  background: #fafbfc;
  color-scheme: light;
}

.snippetEditor:focus {
  outline: none;
  border-color: rgba(94, 225, 255, 0.5);
  box-shadow: 0 0 0 3px rgba(94, 225, 255, 0.12);
}

.snippetPreviewWrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 520px;
  overflow: auto;
  background: #fafbfc;
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  color-scheme: light;
}

#capture {
  display: inline-block;
  max-width: 100%;
  box-sizing: border-box;
  background: #fafbfc;
  padding: 18px;
  color-scheme: light;
}

#capture pre {
  margin: 0;
  color: #0a0a0a;
  background: transparent;
  font-family: var(--font-mono);
  font-size: var(--snippet-font-px, 14px);
  line-height: 1.45;
  white-space: pre;
  width: max-content;
}

#capture .comment {
  color: #6b7280;
}
