:root {
  --ink: #14213d;
  --ink-soft: #3d4f6f;
  --paper: #f3f6f9;
  --paper-deep: #e4ebf2;
  --line: #c5d0dc;
  --accent: #0f766e;
  --accent-bright: #14b8a6;
  --accent-soft: rgba(15, 118, 110, 0.12);
  --danger: #b45309;
  --chrome: #0f1c2e;
  --chrome-soft: #1a2b42;
  --white: #ffffff;
  --shadow: 0 18px 40px rgba(15, 28, 46, 0.12);
  --radius: 14px;
  --font: "Outfit", sans-serif;
  --mono: "JetBrains Mono", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(ellipse 80% 60% at 10% 0%, rgba(20, 184, 166, 0.18), transparent 55%),
    radial-gradient(ellipse 70% 50% at 100% 100%, rgba(20, 33, 61, 0.1), transparent 50%),
    linear-gradient(160deg, #d9e4ef 0%, #eef3f7 45%, #dce7f0 100%);
}

body {
  overflow: hidden;
}

.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  grid-template-rows: 72px auto 1fr;
  height: 100%;
  gap: 0;
  animation: rise-in 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

.topbar {
  grid-column: 1 / -1;
  grid-row: 1;
}

.eq-ribbon {
  grid-column: 1 / -1;
  grid-row: 2;
}

.sidebar {
  grid-row: 3;
}

.stage {
  grid-row: 3;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.25rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(255, 255, 255, 0.55));
  border-bottom: 1px solid rgba(20, 33, 61, 0.08);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 180px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background:
    linear-gradient(135deg, var(--accent-bright), var(--accent)),
    var(--accent);
  box-shadow: 0 8px 18px rgba(15, 118, 110, 0.35);
  position: relative;
  overflow: hidden;
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 8px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 4px;
  border-right-color: transparent;
  border-bottom-color: transparent;
  transform: rotate(45deg) translate(1px, -1px);
}

.brand-text h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.brand-text p {
  margin: 0;
  font-size: 0.72rem;
  color: var(--ink-soft);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.mode-tabs {
  display: flex;
  gap: 0.35rem;
  padding: 0.3rem;
  background: rgba(20, 33, 61, 0.06);
  border-radius: 999px;
}

.mode-tab {
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font: 500 0.9rem var(--font);
  padding: 0.45rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.mode-tab:hover {
  color: var(--ink);
  transform: translateY(-1px);
}

.mode-tab.active {
  background: var(--white);
  color: var(--accent);
  box-shadow: 0 4px 14px rgba(15, 28, 46, 0.1);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.icon-btn,
.btn-primary,
.tool-btn {
  font-family: var(--font);
  cursor: pointer;
}

.icon-btn {
  border: 1px solid rgba(20, 33, 61, 0.12);
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink);
  border-radius: 10px;
  padding: 0.45rem 0.7rem;
  font-size: 0.85rem;
  font-weight: 500;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
}

.icon-btn:hover {
  border-color: var(--accent);
  background: var(--white);
  transform: translateY(-1px);
}

.btn-primary {
  border: 0;
  background: linear-gradient(135deg, var(--accent-bright), var(--accent));
  color: white;
  border-radius: 10px;
  padding: 0.5rem 0.95rem;
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: 0 8px 18px rgba(15, 118, 110, 0.28);
  transition: transform 0.15s, filter 0.15s;
}

.btn-primary:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.sidebar {
  padding: 1rem;
  overflow-y: auto;
  border-right: 1px solid rgba(20, 33, 61, 0.08);
  background: rgba(255, 255, 255, 0.42);
  backdrop-filter: blur(10px);
}

.panel {
  margin-bottom: 1.1rem;
  animation: panel-in 0.35s ease;
}

.panel.hidden {
  display: none;
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateX(-6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.panel h2 {
  margin: 0 0 0.65rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.tool-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
}

.tool-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 0.7rem 0.4rem 0.55rem;
  border: 1px solid rgba(20, 33, 61, 0.1);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.75);
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 500;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s, transform 0.15s;
}

.tool-btn svg {
  width: 28px;
  height: 28px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tool-btn:hover {
  border-color: rgba(15, 118, 110, 0.45);
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(15, 28, 46, 0.08);
}

.tool-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(15, 118, 110, 0.2);
}

.style-panel .field,
.style-panel .toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.style-panel input[type="color"] {
  width: 42px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.style-panel input[type="range"] {
  width: 110px;
  accent-color: var(--accent);
}

.style-panel .toggle {
  justify-content: flex-start;
}

.style-panel .toggle input {
  accent-color: var(--accent);
}

.saved-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 160px;
  overflow-y: auto;
}

.saved-item {
  border: 1px solid rgba(20, 33, 61, 0.1);
  background: rgba(255, 255, 255, 0.75);
  color: var(--ink-soft);
  border-radius: 10px;
  padding: 0.45rem 0.65rem;
  font: 500 0.75rem var(--mono);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.saved-item:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--white);
}

.muted {
  margin: 0;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.modal[hidden] {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: rgba(15, 28, 46, 0.35);
  backdrop-filter: blur(4px);
  animation: panel-in 0.2s ease;
}

.modal-card {
  width: min(420px, calc(100vw - 2rem));
  background: var(--white);
  border-radius: 16px;
  padding: 1.15rem 1.25rem 1.1rem;
  box-shadow: var(--shadow);
  border: 1px solid rgba(20, 33, 61, 0.08);
}

.modal-card h3 {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.modal-note {
  margin: 0 0 0.9rem;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.modal-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ink-soft);
}

.modal-grid input {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.45rem 0.55rem;
  font: 500 0.9rem var(--mono);
  color: var(--ink);
  background: var(--paper);
}

.modal-grid input:focus {
  outline: 2px solid rgba(15, 118, 110, 0.35);
  border-color: var(--accent);
}

.modal-toggle {
  margin: 0.85rem 0 1rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.field-block {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ink-soft);
}

.field-block input {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  font: 500 0.95rem var(--mono);
  color: var(--ink);
  background: var(--paper);
}

.field-block input:focus {
  outline: 2px solid rgba(15, 118, 110, 0.35);
  border-color: var(--accent);
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.preset-row button {
  border: 1px solid rgba(20, 33, 61, 0.12);
  background: rgba(243, 246, 249, 0.9);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 0.3rem 0.65rem;
  font: 500 0.78rem var(--mono);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.preset-row button:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 1rem 1rem 0.75rem;
}

.canvas-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  background: var(--paper);
  border: 1px solid rgba(20, 33, 61, 0.08);
  cursor: crosshair;
}

.canvas-wrap canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.text-editor {
  position: absolute;
  z-index: 20;
  min-width: 160px;
  max-width: min(420px, 80%);
  min-height: 32px;
  margin: 0;
  padding: 0.35rem 0.5rem;
  border: 1.5px solid var(--accent);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font: 600 16px var(--font);
  line-height: 1.3;
  resize: both;
  box-shadow: 0 8px 22px rgba(15, 28, 46, 0.16);
  outline: none;
  pointer-events: auto;
  caret-color: var(--accent);
  -webkit-user-select: text;
  user-select: text;
}

.text-editor[hidden] {
  display: none !important;
}

#btn-text.active,
#btn-symbols.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.symbol-hint {
  margin: -0.2rem 0 0.55rem;
  font-size: 0.72rem;
}

.symbol-palette {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 0.15rem;
}

.symbol-group h3 {
  margin: 0 0 0.35rem;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.symbol-chars {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.symbol-char {
  min-width: 32px;
  height: 32px;
  padding: 0 0.35rem;
  border: 1px solid rgba(20, 33, 61, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.85);
  color: var(--ink);
  font: 600 0.95rem var(--mono);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.12s;
}

.symbol-char:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  transform: translateY(-1px);
}

.symbol-popover[hidden] {
  display: none !important;
}

.symbol-popover {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: start center;
  padding-top: 4.5rem;
  background: rgba(15, 28, 46, 0.28);
  backdrop-filter: blur(3px);
}

.symbol-popover-card {
  width: min(520px, calc(100vw - 1.5rem));
  max-height: min(70vh, 560px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--white);
  border-radius: 16px;
  border: 1px solid rgba(20, 33, 61, 0.08);
  box-shadow: var(--shadow);
  animation: panel-in 0.2s ease;
}

.symbol-popover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid rgba(20, 33, 61, 0.08);
}

.symbol-palette-pop {
  max-height: none;
  overflow-y: auto;
  padding: 0.85rem 1rem 1rem;
}

#btn-equations.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.mini-menu[hidden] {
  display: none !important;
}

.mini-menu {
  position: fixed;
  z-index: 120;
  min-width: 190px;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.35rem;
  background: #fff;
  border: 1px solid rgba(20, 33, 61, 0.12);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.mini-menu button {
  border: 0;
  background: transparent;
  text-align: left;
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  font: 500 0.85rem var(--font);
  color: var(--ink);
  cursor: pointer;
}

.mini-menu button:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

#btn-eq-tools.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.eq-ribbon[hidden] {
  display: none !important;
}

.eq-ribbon {
  border-bottom: 1px solid rgba(20, 33, 61, 0.1);
  background: linear-gradient(180deg, #f7fafc 0%, #eef3f8 100%);
  overflow-x: auto;
}

.eq-ribbon-inner {
  display: flex;
  align-items: stretch;
  gap: 0;
  min-width: max-content;
  padding: 0.45rem 0.75rem 0.35rem;
}

.eq-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 0 0.75rem;
  border-right: 1px solid rgba(20, 33, 61, 0.1);
}

.eq-group:last-child {
  border-right: 0;
}

.eq-group-label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.eq-group-tools {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 64px;
}

.eq-tool {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 8px;
  padding: 0.35rem 0.55rem;
  font: 500 0.72rem var(--font);
  color: var(--ink);
  cursor: pointer;
}

.eq-tool:hover,
.eq-tool.active {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(15, 118, 110, 0.35);
}

.eq-tool-icon {
  font-size: 1.25rem;
  line-height: 1;
  color: var(--accent);
}

.eq-chip {
  border: 1px solid rgba(20, 33, 61, 0.12);
  background: rgba(255, 255, 255, 0.75);
  color: var(--ink-soft);
  border-radius: 8px;
  padding: 0.4rem 0.55rem;
  font: 600 0.75rem var(--font);
  cursor: pointer;
}

.eq-chip.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.eq-group-symbols {
  min-width: 280px;
  max-width: 360px;
  align-items: stretch;
}

.eq-symbol-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
}

.eq-sym-tab {
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font: 500 0.65rem var(--font);
  padding: 0.15rem 0.35rem;
  border-radius: 6px;
  cursor: pointer;
}

.eq-sym-tab.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.eq-symbol-grid {
  min-height: 52px;
}

.eq-sym-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem;
}

.eq-sym-panel.hidden {
  display: none;
}

.eq-sym {
  width: 26px;
  height: 26px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  font: 600 0.9rem "Cambria Math", "Times New Roman", serif;
  color: var(--ink);
  cursor: pointer;
}

.eq-sym:hover {
  border-color: var(--accent);
  background: #fff;
}

.eq-group-structures {
  align-items: stretch;
}

.eq-structures {
  display: flex;
  gap: 0.25rem;
  min-height: 64px;
  align-items: flex-start;
}

.eq-struct-wrap {
  position: relative;
}

.eq-struct {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  width: 72px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 8px;
  padding: 0.3rem 0.2rem;
  font: 500 0.65rem var(--font);
  color: var(--ink-soft);
  cursor: pointer;
}

.eq-struct:hover,
.eq-struct.open {
  background: #fff;
  border-color: rgba(15, 118, 110, 0.35);
  color: var(--accent);
}

.eq-struct-icon {
  font: 600 0.95rem "Cambria Math", "Times New Roman", serif;
  color: var(--ink);
}

.eq-struct-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 100;
  min-width: 200px;
  max-height: 260px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid rgba(20, 33, 61, 0.12);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 0.35rem;
}

.eq-struct-menu[hidden] {
  display: none !important;
}

.eq-struct-item {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: 8px;
  padding: 0.4rem 0.5rem;
  cursor: pointer;
}

.eq-struct-item:hover {
  background: var(--accent-soft);
}

.eq-struct-item strong {
  font-size: 0.72rem;
  color: var(--ink);
}

.eq-struct-item code {
  font: 500 0.78rem var(--mono);
  color: var(--ink-soft);
}

.ink-modal[hidden] {
  display: none !important;
}

.ink-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: rgba(15, 28, 46, 0.4);
  backdrop-filter: blur(4px);
}

.ink-card {
  width: min(720px, calc(100vw - 1.5rem));
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.ink-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(20, 33, 61, 0.08);
}

.ink-head h3 {
  margin: 0;
  font-size: 1.05rem;
}

.ink-body {
  padding: 0.85rem 1rem 1rem;
}

.ink-canvas-wrap {
  border: 1px dashed rgba(20, 33, 61, 0.25);
  border-radius: 12px;
  background:
    linear-gradient(rgba(15, 118, 110, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 118, 110, 0.04) 1px, transparent 1px),
    #f8fafc;
  background-size: 24px 24px;
  height: 220px;
  cursor: crosshair;
  overflow: hidden;
}

#ink-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.ink-preview {
  margin-top: 0.75rem;
  width: 100%;
  box-sizing: border-box;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  background: var(--paper);
  border: 1px solid var(--line);
  font: 600 1.05rem "Cambria Math", "Times New Roman", serif;
  min-height: 2.6rem;
  color: var(--ink);
  outline: none;
  resize: vertical;
}

.ink-preview:focus {
  border-color: var(--accent);
  outline: 2px solid rgba(15, 118, 110, 0.25);
}

.ink-status {
  margin-top: 0.55rem;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font: 500 0.82rem var(--font);
}

.ink-presets {
  margin-top: 0.55rem;
}

.ink-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.45rem;
  margin-top: 0.85rem;
  flex-wrap: wrap;
}

.equation-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-bottom: 0.55rem;
}

.equation-tab {
  border: 1px solid rgba(20, 33, 61, 0.1);
  background: rgba(255, 255, 255, 0.75);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 0.28rem 0.55rem;
  font: 500 0.68rem var(--font);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.equation-tab:hover,
.equation-tab.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.equation-list {
  max-height: 200px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.equation-group.hidden {
  display: none;
}

.equation-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  width: 100%;
  text-align: left;
  border: 1px solid rgba(20, 33, 61, 0.1);
  background: rgba(255, 255, 255, 0.85);
  border-radius: 10px;
  padding: 0.45rem 0.55rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.12s;
}

.equation-item:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-1px);
}

.eq-name {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.eq-body {
  font: 500 0.82rem var(--mono);
  color: var(--ink);
  line-height: 1.35;
  word-break: break-word;
}

.equation-popover-card {
  width: min(640px, calc(100vw - 1.5rem));
  max-height: min(78vh, 640px);
}

.equation-tabs-pop {
  padding: 0.65rem 1rem 0;
}

.equation-list-pop {
  max-height: none;
  overflow-y: auto;
  padding: 0.55rem 1rem 1rem;
}

#main-canvas {
  z-index: 1;
}

.status {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 0.25rem 0.2rem;
  font-size: 0.78rem;
  color: var(--ink-soft);
  font-family: var(--mono);
}

#status-tool {
  color: var(--accent);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--chrome);
  color: white;
  padding: 0.65rem 1rem;
  border-radius: 999px;
  font-size: 0.85rem;
  box-shadow: 0 12px 30px rgba(15, 28, 46, 0.3);
  z-index: 50;
  animation: toast-in 0.3s ease;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
  }

  .topbar {
    flex-wrap: wrap;
    padding: 0.75rem;
    row-gap: 0.6rem;
  }

  .brand {
    min-width: auto;
  }

  .mode-tabs {
    order: 3;
    width: 100%;
    overflow-x: auto;
  }

  .sidebar {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid rgba(20, 33, 61, 0.08);
    padding: 0.75rem;
  }

  .panel {
    min-width: 220px;
    margin-bottom: 0;
  }

  .status {
    flex-wrap: wrap;
  }

  #status-hint {
    display: none;
  }
}
