/* Excalidraw recreation — UI chrome styles.
   Values measured from excalidraw.com (see workspace/reference/facts.md). */

:root {
  --color-primary: #6965db;
  --color-primary-darker: #5b57d1;
  --color-primary-darkest: #4a47b1;
  --color-primary-light: #e3e2fe;
  --island-bg: #ffffff;
  --island-shadow: 0 0 1px rgba(0, 0, 0, 0.17), 0 0 3px rgba(0, 0, 0, 0.08),
    0 7px 14px rgba(0, 0, 0, 0.05);
  --text-color: #1b1b1f;
  --text-muted: #7a7a85;
  --button-hover-bg: #f1f0ff;
  --button-active-bg: #e0dfff;
  --button-active-color: #030064;
  --default-border: #e9ecef;
  --input-bg: #f1f3f5;
  --context-menu-bg: #f1f3f5;
  --dialog-overlay: rgba(18, 18, 18, 0.2);
  --scrollbar: #ced4da;
  --theme-filter: none;
  --welcome-color: #b8b8c5;
  --key-badge-color: #b8b8b8;
  --surface-low: #ececf4;
  --context-menu-item-hover: #e3e2fe;
  --slider-track: hsl(240, 100%, 90%);
  --slider-thumb: #3d3d3d;
}

[data-theme="dark"] {
  --color-primary: #a8a5ff;
  --color-primary-darker: #b2aeff;
  --color-primary-darkest: #beb9ff;
  --color-primary-light: #4f4d6f;
  --island-bg: #232329;
  --island-shadow: 0 0 1px rgba(0, 0, 0, 0.5), 0 0 3px rgba(0, 0, 0, 0.35),
    0 7px 14px rgba(0, 0, 0, 0.3);
  --text-color: #e3e3e8;
  --text-muted: #8e8e9c;
  --button-hover-bg: #2e2d39;
  --button-active-bg: #403e6a;
  --button-active-color: #e0dfff;
  --default-border: #2e2e38;
  --input-bg: #31303b;
  --context-menu-bg: #232329;
  --dialog-overlay: rgba(0, 0, 0, 0.45);
  --scrollbar: #494950;
  --theme-filter: invert(93%) hue-rotate(180deg);
  --welcome-color: #64646e;
  --key-badge-color: #7a7a7a;
  --surface-low: #26262e;
  --context-menu-item-hover: #403e6a;
  --slider-track: #4f4d6f;
  --slider-thumb: #e3e3e8;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: "Assistant", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  color: var(--text-color);
  background: #ffffff;
}

[data-theme="dark"] body,
[data-theme="dark"] .excalidraw-app {
  background: #121212;
}

.excalidraw-app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  touch-action: none;
}

.excalidraw__canvas {
  position: absolute;
  top: 0;
  left: 0;
  touch-action: none;
}

[data-theme="dark"] .static-canvas {
  filter: var(--theme-filter);
}

.interactive-canvas {
  z-index: 2;
}

/* ---------- islands & buttons ---------- */

.island {
  background: var(--island-bg);
  border-radius: 8px;
  box-shadow: var(--island-shadow);
}

button {
  font-family: inherit;
  border: none;
  background: none;
  color: var(--text-color);
  cursor: pointer;
  padding: 0;
}

button:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 1px;
}

button svg {
  width: 20px;
  height: 20px;
  display: block;
}

/* ---------- top bar ---------- */

.app-top-bar {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  z-index: 4;
  pointer-events: none;
}

.app-top-bar > * {
  pointer-events: auto;
}

.app-top-left,
.app-top-right {
  width: 100px;
  display: flex;
}

.app-top-right {
  justify-content: flex-end;
}

.toolbar-wrap {
  flex: 0 1 auto;
  display: flex;
  justify-content: center;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 4px;
}

.toolbar-button {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  color: var(--text-color);
}

.toolbar-button:hover {
  background: var(--button-hover-bg);
}

.toolbar-button.active {
  background: var(--button-active-bg);
  color: var(--button-active-color);
}

.toolbar-button .key-badge {
  position: absolute;
  right: 3px;
  bottom: 2px;
  font-size: 9.5px;
  color: var(--key-badge-color);
  user-select: none;
}

.toolbar-button.active .key-badge {
  color: var(--button-active-color);
  opacity: 0.6;
}

.lock-button {
  width: 32px;
}

.lock-button svg {
  width: 17px;
  height: 17px;
}

.toolbar-separator {
  width: 1px;
  align-self: stretch;
  margin: 6px 4px;
  background: var(--default-border);
}

.burger-button {
  width: 36px;
  height: 36px;
}

.main-menu {
  position: relative;
}

.main-menu-dropdown {
  position: absolute;
  top: 44px;
  left: 0;
  width: 226px;
  padding: 8px;
  z-index: 10;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}

/* ---------- menu items ---------- */

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 34px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 14px;
  text-align: left;
  text-decoration: none;
  color: var(--text-color);
}

.menu-item:hover {
  background: var(--button-hover-bg);
}

.menu-item.danger:hover {
  background: #ffe3e3;
  color: #c92a2a;
}

[data-theme="dark"] .menu-item.danger:hover {
  background: #46262a;
  color: #ff8787;
}

.menu-item-icon {
  display: flex;
  color: var(--text-muted);
}

.menu-item-icon svg {
  width: 16px;
  height: 16px;
}

.menu-item-label {
  flex: 1;
}

.menu-item-shortcut {
  font-size: 12px;
  color: var(--text-muted);
}

.menu-separator {
  height: 1px;
  background: var(--default-border);
  margin: 6px 0;
}

.menu-theme-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  font-size: 14px;
}

.menu-canvas-bg {
  padding: 4px 8px 6px;
}

/* ---------- left properties panel ---------- */

.panel-wrap {
  position: absolute;
  top: 70px;
  left: 16px;
  z-index: 3;
  max-height: calc(100% - 150px);
  display: flex;
}

.panel {
  width: 202px;
  padding: 12px 12px 4px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar) transparent;
}

.panel-section {
  margin-bottom: 10px;
}

.panel-label {
  font-size: 12px;
  margin-bottom: 6px;
  color: var(--text-color);
}

.button-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.button-row.wrap {
  flex-wrap: wrap;
}

.option-button {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--input-bg);
  color: var(--text-color);
}

.option-button svg {
  width: 16px;
  height: 16px;
}

.option-button:hover {
  background: var(--button-hover-bg);
}

.option-button.active {
  background: var(--button-active-bg);
  color: var(--button-active-color);
}

.option-text {
  font-size: 13px;
  font-weight: 600;
}

.arrowhead-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* color swatches */

.color-row {
  gap: 5px;
}

.color-swatch {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  position: relative;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .color-swatch {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}

.color-swatch svg {
  width: 100%;
  height: 100%;
  border-radius: 4px;
}

.color-swatch:hover {
  transform: scale(1.08);
}

.color-swatch.active {
  box-shadow: 0 0 0 1px var(--island-bg), 0 0 0 2.5px var(--color-primary);
}

.color-swatch.current {
  width: 26px;
  height: 26px;
}

.color-divider {
  width: 1px;
  height: 22px;
  background: var(--default-border);
  margin: 0 2px;
}

.color-picker-popover {
  position: fixed;
  z-index: 30;
  padding: 12px;
  width: 216px;
}

.picker-title {
  font-size: 12px;
  margin-bottom: 8px;
  color: var(--text-muted);
}

.picker-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}

.hex-row {
  display: flex;
  align-items: center;
  background: var(--input-bg);
  border-radius: 6px;
  padding: 0 8px;
}

.hex-hash {
  color: var(--text-muted);
  font-size: 13px;
}

.hex-input {
  flex: 1;
  border: none;
  background: none;
  height: 30px;
  padding: 0 4px;
  font-family: inherit;
  font-size: 13px;
  color: var(--text-color);
  outline: none;
  min-width: 0;
}

/* opacity slider */

.opacity-wrap {
  padding: 2px 1px;
}

.opacity-slider {
  width: 100%;
  height: 4px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background: var(--slider-track);
  border-radius: 2px;
  outline: none;
}

.opacity-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--slider-thumb);
  border: none;
  cursor: pointer;
}

.opacity-slider::-moz-range-thumb {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--slider-thumb);
  border: none;
  cursor: pointer;
}

.opacity-marks {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ---------- footer ---------- */

.app-footer {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  z-index: 4;
  pointer-events: none;
}

.footer-left {
  display: flex;
  gap: 12px;
  pointer-events: auto;
}

.footer-right {
  pointer-events: auto;
}

.footer-island {
  display: flex;
  align-items: center;
  padding: 0;
  height: 36px;
  background: var(--surface-low);
  box-shadow: none;
}

.footer-button {
  height: 36px;
  min-width: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-color);
  font-size: 12px;
}

.footer-button:hover {
  background: var(--button-hover-bg);
}

.footer-button:disabled {
  opacity: 0.4;
  cursor: default;
  background: none;
}

.footer-button svg {
  width: 16px;
  height: 16px;
}

.zoom-pct {
  min-width: 56px;
  font-variant-numeric: tabular-nums;
}

.help-button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.help-button:hover {
  color: var(--text-color);
}

/* ---------- context menu ---------- */

.context-menu {
  position: fixed;
  z-index: 40;
  min-width: 268px;
  padding: 8px 0;
  border-radius: 4px;
  background: var(--context-menu-bg);
  box-shadow: rgba(0, 0, 0, 0.2) 0 3px 10px;
}

.context-menu .menu-item {
  height: 30px;
  font-size: 14px;
  border-radius: 0;
  padding: 0 14px;
}

.context-menu .menu-item:hover {
  background: var(--context-menu-item-hover);
}

.context-menu .menu-separator {
  margin: 6px 8px;
}

/* ---------- tooltips ---------- */

.excalidraw-tooltip {
  position: fixed;
  z-index: 100;
  background: #16161d;
  color: #fff;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 6px;
  pointer-events: none;
  display: none;
  max-width: 260px;
}

[data-theme="dark"] .excalidraw-tooltip {
  background: #e3e3e8;
  color: #16161d;
}

/* ---------- dialogs ---------- */

.dialog-overlay {
  position: fixed;
  inset: 0;
  background: var(--dialog-overlay);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dialog {
  max-width: min(760px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  padding: 20px 24px;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.dialog-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
}

.dialog-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dialog-close:hover {
  background: var(--button-hover-bg);
}

.dialog-close svg {
  width: 18px;
  height: 18px;
}

.dialog-button {
  height: 38px;
  padding: 0 16px;
  border-radius: 8px;
  background: var(--input-bg);
  font-size: 14px;
  font-weight: 600;
}

.dialog-button.primary {
  background: var(--color-primary);
  color: #fff;
}

.dialog-button.primary:hover {
  background: var(--color-primary-darker);
}

[data-theme="dark"] .dialog-button.primary {
  color: #121212;
}

.dialog-button.danger {
  background: #e03131;
  color: #fff;
}

.export-body {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.export-preview {
  width: 320px;
  height: 260px;
  border-radius: 8px;
  background: var(--input-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background-image: conic-gradient(
    rgba(0, 0, 0, 0.06) 0 25%,
    transparent 0 50%,
    rgba(0, 0, 0, 0.06) 0 75%,
    transparent 0
  );
  background-size: 20px 20px;
}

.export-preview-canvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.export-empty {
  color: var(--text-muted);
}

.export-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 220px;
  flex: 1;
}

.export-name-input {
  width: 100%;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: var(--input-bg);
  padding: 0 12px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-color);
  outline: none;
}

.export-option {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}

.export-option input {
  accent-color: var(--color-primary);
  width: 16px;
  height: 16px;
}

.export-scale-label {
  font-size: 12px;
  color: var(--text-muted);
}

.scale-row .option-button {
  width: 44px;
  font-size: 13px;
  font-weight: 600;
}

.export-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.export-status {
  font-size: 13px;
  color: var(--color-primary);
  min-height: 18px;
}

.confirm-body p {
  margin: 0 0 16px;
  font-size: 15px;
}

/* help dialog */

.help-dialog {
  width: min(860px, calc(100vw - 32px));
}

.help-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 8px 28px;
}

.help-section-title {
  font-size: 14px;
  margin: 8px 0 6px;
  color: var(--color-primary);
}

.help-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 13px;
  padding: 3px 0;
  border-bottom: 1px solid var(--default-border);
}

.help-label {
  color: var(--text-color);
}

.help-keys {
  color: var(--text-muted);
  white-space: nowrap;
  font-size: 12px;
}

/* ---------- text editor ---------- */

.excalidraw-wysiwyg {
  position: fixed;
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
  outline: none;
  resize: none;
  background: transparent;
  overflow: hidden;
  white-space: pre;
  word-break: normal;
  z-index: 5;
  -webkit-font-smoothing: antialiased;
  caret-color: var(--color-primary);
}

.excalidraw-wysiwyg[wrap="soft"] {
  white-space: pre-wrap;
  word-break: break-word;
}

[data-theme="dark"] .excalidraw-wysiwyg {
  filter: var(--theme-filter);
}

/* ---------- hint viewer & scroll-back ---------- */

.hint-wrap {
  position: absolute;
  top: 64px;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  z-index: 3;
}

.hint-viewer {
  font-size: 12.5px;
  color: var(--text-muted);
  min-height: 16px;
  text-align: center;
  padding: 0 12px;
}

.scroll-back-button {
  pointer-events: auto;
  height: 34px;
  padding: 0 14px;
  font-size: 13px;
  color: var(--text-color);
  border-radius: 8px;
}

.scroll-back-button:hover {
  background: var(--button-hover-bg);
}

/* ---------- welcome screen ---------- */

.welcome-screen {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  color: var(--welcome-color);
}

.welcome-screen.hidden {
  display: none;
}

.welcome-center {
  position: absolute;
  top: 42%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.welcome-logo {
  font-family: "Excalifont", "Virgil", cursive;
  font-size: 44px;
  letter-spacing: 1px;
}

.welcome-subtitle {
  font-family: "Excalifont", "Virgil", cursive;
  margin-top: 10px;
  font-size: 17px;
}

.welcome-shortcuts {
  margin-top: 28px;
  font-size: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.welcome-shortcuts kbd {
  font-family: inherit;
  background: transparent;
  border: 1px solid var(--welcome-color);
  border-radius: 4px;
  padding: 0 5px;
  font-size: 12px;
}

.welcome-hint-toolbar {
  position: absolute;
  top: 72px;
  left: 50%;
  transform: translateX(40px);
  display: flex;
  gap: 6px;
  align-items: flex-start;
  font-family: "Excalifont", "Virgil", cursive;
  font-size: 15px;
}

.welcome-hint-toolbar .hint-arrow svg {
  width: 30px;
  height: 42px;
}

.welcome-hint-toolbar .hint-text {
  margin-top: 24px;
}

.welcome-hint-menu {
  position: absolute;
  top: 66px;
  left: 62px;
  display: flex;
  gap: 4px;
  font-family: "Excalifont", "Virgil", cursive;
  font-size: 15px;
}

.welcome-hint-menu .hint-arrow svg {
  width: 44px;
  height: 32px;
}

.welcome-hint-menu .hint-text {
  margin-top: 22px;
  max-width: 160px;
}

/* ---------- responsive ---------- */

@media (max-width: 860px) {
  .app-top-left,
  .app-top-right {
    width: auto;
  }

  .app-top-bar {
    left: 8px;
    right: 8px;
    top: 8px;
    gap: 8px;
  }

  .toolbar {
    overflow-x: auto;
    max-width: calc(100vw - 120px);
    scrollbar-width: none;
  }

  .toolbar::-webkit-scrollbar {
    display: none;
  }

  .panel-wrap {
    left: 8px;
    top: 60px;
    max-height: calc(100% - 130px);
  }

  .panel {
    width: 196px;
    padding: 10px 10px 4px;
  }

  .app-footer {
    left: 8px;
    right: 8px;
    bottom: 8px;
  }

  .welcome-hint-menu,
  .welcome-hint-toolbar {
    display: none;
  }

  .export-preview {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .footer-left {
    gap: 6px;
  }

  .zoom-pct {
    min-width: 44px;
  }

  .welcome-logo {
    font-size: 34px;
  }
}
