/* ─── ForgeCAD Mobile ─── */

.fc-mobile {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh; /* dynamic viewport height — excludes mobile browser chrome */
  width: 100vw;
  overflow: hidden;
  background: var(--fc-bg);
  color: var(--fc-text);
  font-family: system-ui, -apple-system, sans-serif;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* ─── Top bar ─── */

.fc-mobile-topbar {
  display: flex;
  align-items: center;
  height: 44px;
  min-height: 44px;
  padding: 0 8px;
  background: var(--fc-bgPanel);
  border-bottom: 1px solid var(--fc-border);
  gap: 8px;
  z-index: 10;
}

.fc-mobile-topbar-title {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--fc-text);
}

.fc-mobile-topbar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 44px;
  background: none;
  border: none;
  color: var(--fc-text);
  font-size: 13px;
  padding: 0 8px;
  cursor: pointer;
  border-radius: 6px;
}

.fc-mobile-topbar-btn:active {
  background: var(--fc-bgHover);
}

/* ─── Content area ─── */

.fc-mobile-content {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.fc-mobile-tab-panel {
  position: absolute;
  inset: 0;
  display: none;
}

.fc-mobile-tab-panel[data-active="true"] {
  display: flex;
  flex-direction: column;
}

/* ─── Bottom bar ─── */

.fc-mobile-bottombar {
  display: flex;
  align-items: center;
  height: 52px;
  min-height: 52px;
  padding: 0 4px;
  background: var(--fc-bgPanel);
  border-top: 1px solid var(--fc-border);
  gap: 0;
  z-index: 10;
}

.fc-mobile-tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: 52px;
  background: none;
  border: none;
  color: var(--fc-textMuted);
  font-size: 10px;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
  border-radius: 0;
}

.fc-mobile-tab-btn[data-active="true"] {
  color: var(--fc-accent);
}

.fc-mobile-tab-btn:active {
  background: var(--fc-bgHover);
}

.fc-mobile-tab-icon {
  font-size: 20px;
  line-height: 1;
}

.fc-mobile-run-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  height: 40px;
  margin: 0 4px;
  background: var(--fc-accent);
  color: var(--fc-accentText, #fff);
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  gap: 6px;
  padding: 0 16px;
}

.fc-mobile-run-btn:active {
  opacity: 0.8;
}

.fc-mobile-run-btn:disabled {
  opacity: 0.5;
}

/* ─── Code editor (overlay pattern: highlighted pre + transparent textarea) ─── */

.fc-mobile-editor-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 0;
}

.fc-mobile-editor-highlight,
.fc-mobile-editor {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 12px;
  font-family: "SF Mono", "Menlo", "Consolas", monospace;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre;
  overflow: auto;
  border: none;
  -webkit-text-size-adjust: none;
  tab-size: 2;
  word-wrap: normal;
}

.fc-mobile-editor-highlight {
  background: var(--fc-bgInput, var(--fc-bg));
  color: var(--fc-text);
  pointer-events: none;
  z-index: 0;
}

.fc-mobile-editor {
  background: transparent;
  color: transparent;
  caret-color: var(--fc-text);
  z-index: 1;
  resize: none;
  outline: none;
}

/* ─── highlight.js token colours (tuned for dark themes) ─── */
.fc-mobile-editor-highlight .hljs-keyword {
  color: #c586c0;
}
.fc-mobile-editor-highlight .hljs-string {
  color: #ce9178;
}
.fc-mobile-editor-highlight .hljs-number {
  color: #b5cea8;
}
.fc-mobile-editor-highlight .hljs-comment {
  color: #6a9955;
  font-style: italic;
}
.fc-mobile-editor-highlight .hljs-function {
  color: #dcdcaa;
}
.fc-mobile-editor-highlight .hljs-title {
  color: #dcdcaa;
}
.fc-mobile-editor-highlight .hljs-params {
  color: #9cdcfe;
}
.fc-mobile-editor-highlight .hljs-built_in {
  color: #4ec9b0;
}
.fc-mobile-editor-highlight .hljs-literal {
  color: #569cd6;
}
.fc-mobile-editor-highlight .hljs-attr {
  color: #9cdcfe;
}
.fc-mobile-editor-highlight .hljs-property {
  color: #9cdcfe;
}
.fc-mobile-editor-highlight .hljs-variable {
  color: #9cdcfe;
}
.fc-mobile-editor-highlight .hljs-regexp {
  color: #d16969;
}
.fc-mobile-editor-highlight .hljs-operator {
  color: #d4d4d4;
}
.fc-mobile-editor-highlight .hljs-punctuation {
  color: #d4d4d4;
}

/* ─── Viewport ─── */

.fc-mobile-viewport {
  flex: 1;
  width: 100%;
  position: relative;
}

.fc-mobile-viewport-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--fc-textDim);
  font-size: 13px;
  background: var(--fc-bg);
  z-index: 5;
}

/* ─── File picker overlay ─── */

.fc-mobile-filepicker-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 100;
  display: flex;
  align-items: flex-end;
}

.fc-mobile-filepicker-sheet {
  width: 100%;
  max-height: 60vh;
  background: var(--fc-bgPanel);
  border-radius: 12px 12px 0 0;
  overflow-y: auto;
  padding: 8px 0;
  padding-bottom: env(safe-area-inset-bottom, 8px);
}

.fc-mobile-filepicker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-bottom: 1px solid var(--fc-border);
  font-size: 14px;
  font-weight: 600;
}

.fc-mobile-filepicker-item {
  display: flex;
  align-items: center;
  width: 100%;
  height: 48px;
  padding: 0 16px;
  background: none;
  border: none;
  color: var(--fc-text);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  gap: 10px;
}

.fc-mobile-filepicker-item:active {
  background: var(--fc-bgHover);
}

.fc-mobile-filepicker-item[data-active="true"] {
  color: var(--fc-accent);
  font-weight: 600;
}

/* ─── Export sheet ─── */

.fc-mobile-export-sheet {
  width: 100%;
  background: var(--fc-bgPanel);
  border-radius: 12px 12px 0 0;
  padding: 8px 0;
  padding-bottom: env(safe-area-inset-bottom, 8px);
}

.fc-mobile-export-item {
  display: flex;
  align-items: center;
  width: 100%;
  height: 52px;
  padding: 0 16px;
  background: none;
  border: none;
  color: var(--fc-text);
  font-size: 15px;
  text-align: left;
  cursor: pointer;
  gap: 12px;
}

.fc-mobile-export-item:active {
  background: var(--fc-bgHover);
}

/* ─── Params panel (inline in code tab) ─── */

.fc-mobile-params {
  border-top: 1px solid var(--fc-border);
  padding: 8px 12px;
  background: var(--fc-bgPanel);
  max-height: 30vh;
  overflow-y: auto;
}

.fc-mobile-param-row {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
}

.fc-mobile-param-label {
  font-size: 12px;
  color: var(--fc-textMuted);
  min-width: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fc-mobile-param-slider {
  flex: 1;
  height: 32px;
  accent-color: var(--fc-accent);
}

.fc-mobile-param-value {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--fc-text);
  min-width: 40px;
  text-align: right;
}

/* ─── Joint / Animation controls ─── */

.fc-mobile-joints {
  border-top: 1px solid var(--fc-border);
  background: var(--fc-bgPanel);
  max-height: 40vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.fc-mobile-joints-section {
  padding: 8px 12px;
}

.fc-mobile-joints-section + .fc-mobile-joints-section {
  border-top: 1px solid var(--fc-borderLight, var(--fc-border));
}

.fc-mobile-joints-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--fc-textDim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.fc-mobile-joints-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
}

.fc-mobile-joints-select {
  flex: 1;
  min-width: 0;
  height: 36px;
  padding: 0 8px;
  background: var(--fc-bgInput, var(--fc-bg));
  border: 1px solid var(--fc-border);
  border-radius: 6px;
  color: var(--fc-text);
  font-size: 13px;
  -webkit-appearance: none;
  appearance: none;
}

.fc-mobile-joints-playbtn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 36px;
  flex-shrink: 0;
  background: var(--fc-bgInput, var(--fc-bg));
  border: 1px solid var(--fc-border);
  border-radius: 6px;
  color: var(--fc-text);
  cursor: pointer;
}

.fc-mobile-joints-playbtn.active {
  background: var(--fc-accent);
  border-color: var(--fc-accent);
  color: var(--fc-accentText, #fff);
}

.fc-mobile-joints-playbtn:disabled {
  opacity: 0.4;
}

.fc-mobile-joints-slider {
  flex: 1;
  height: 36px;
  accent-color: var(--fc-accent);
}

.fc-mobile-joints-value {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--fc-textDim);
  text-align: right;
  flex-shrink: 0;
}

.fc-mobile-joints-info {
  font-size: 11px;
  color: var(--fc-textDim);
  margin-top: 4px;
}

.fc-mobile-joint-item {
  margin-bottom: 6px;
}

.fc-mobile-joint-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
}

.fc-mobile-joint-name {
  font-size: 12px;
  color: var(--fc-text);
}

.fc-mobile-joint-value {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  font-family: "SF Mono", "Menlo", "Consolas", monospace;
  color: var(--fc-accent);
}

/* ─── Status indicator ─── */

.fc-mobile-status {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--fc-bgOverlay, rgba(0, 0, 0, 0.7));
  color: var(--fc-text);
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  z-index: 20;
  pointer-events: none;
  backdrop-filter: blur(4px);
}

/* ─── Error display ─── */

.fc-mobile-error {
  padding: 8px 12px;
  background: var(--fc-errorBg);
  color: var(--fc-error);
  font-size: 12px;
  font-family: "SF Mono", "Menlo", "Consolas", monospace;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 120px;
  overflow-y: auto;
  border-top: 1px solid var(--fc-error);
}

/* ─── Safe area insets ─── */

@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .fc-mobile-bottombar {
    padding-bottom: env(safe-area-inset-bottom);
    height: calc(52px + env(safe-area-inset-bottom));
    min-height: calc(52px + env(safe-area-inset-bottom));
  }
}

/* ─── Command Palette ─── */

.fc-mobile-cmdpal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  animation: fc-mobile-fade-in 0.15s ease-out;
}

@keyframes fc-mobile-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.fc-mobile-cmdpal-sheet {
  width: 100%;
  max-height: 70vh;
  background: var(--fc-bgPanel);
  border-radius: 12px 12px 0 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: env(safe-area-inset-bottom, 8px);
  animation: fc-mobile-slide-up 0.2s ease-out;
}

@keyframes fc-mobile-slide-up {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

.fc-mobile-cmdpal-header {
  display: flex;
  align-items: center;
  padding: 12px 16px 8px;
  gap: 8px;
}

.fc-mobile-cmdpal-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--fc-text);
}

.fc-mobile-cmdpal-back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  color: var(--fc-accent);
  cursor: pointer;
  padding: 0;
  border-radius: 6px;
}

.fc-mobile-cmdpal-back:active {
  background: var(--fc-bgHover);
}

.fc-mobile-cmdpal-close {
  background: none;
  border: none;
  color: var(--fc-accent);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 8px;
}

.fc-mobile-cmdpal-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 12px 8px;
  padding: 8px 12px;
  background: var(--fc-bgInput, var(--fc-bg));
  border: 1px solid var(--fc-border);
  border-radius: 8px;
}

.fc-mobile-cmdpal-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--fc-text);
  font-size: 15px;
  outline: none;
  font-family: inherit;
  padding: 0;
  min-width: 0;
}

.fc-mobile-cmdpal-input::placeholder {
  color: var(--fc-textDim);
}

.fc-mobile-cmdpal-clear {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: none;
  border: none;
  color: var(--fc-textMuted);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

.fc-mobile-cmdpal-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 0 8px;
}

.fc-mobile-cmdpal-item {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 48px;
  padding: 10px 16px;
  background: none;
  border: none;
  color: var(--fc-text);
  font-size: 15px;
  text-align: left;
  cursor: pointer;
  gap: 12px;
  font-family: inherit;
}

.fc-mobile-cmdpal-item:active {
  background: var(--fc-bgHover);
}

.fc-mobile-cmdpal-item-icon {
  font-size: 18px;
  width: 28px;
  text-align: center;
  flex-shrink: 0;
}

.fc-mobile-cmdpal-item-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fc-mobile-cmdpal-empty {
  padding: 20px 16px;
  text-align: center;
  color: var(--fc-textDim);
  font-size: 14px;
}

/* ── Topbar title as command trigger ── */

.fc-mobile-topbar-title[data-tappable="true"] {
  cursor: pointer;
  border-radius: 6px;
  padding: 2px 8px;
  margin: 0 -8px;
}

.fc-mobile-topbar-title[data-tappable="true"]:active {
  background: var(--fc-bgHover);
}

/* ─── Spinner ─── */

@keyframes fc-mobile-spin {
  to {
    transform: rotate(360deg);
  }
}

.fc-mobile-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--fc-textDim);
  border-top-color: var(--fc-accent);
  border-radius: 50%;
  animation: fc-mobile-spin 0.6s linear infinite;
}
/* ============================================================
   ForgeCAD — Global UI Polish Layer
   Adds transitions, hover states, custom scrollbars, and micro-
   interactions to every interactive element in the app.
   ============================================================ */

/* --- Selection color --- */
::selection {
  background: var(--fc-accent);
  color: var(--fc-accentText);
}

/* --- Custom scrollbars (WebKit + Firefox) --- */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--fc-border);
  border-radius: 4px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--fc-textDim);
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-corner {
  background: transparent;
}
/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--fc-border) transparent;
}

/* --- Universal interactive element transitions --- */
button,
[role="button"],
a,
input,
select,
textarea {
  transition:
    background 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    opacity 0.15s ease,
    transform 0.1s ease;
}

/* --- Button hover/active/focus states --- */
button:not(:disabled):hover,
[role="button"]:not(:disabled):hover {
  filter: brightness(1.15);
}
button:not(:disabled):active,
[role="button"]:not(:disabled):active {
  transform: scale(0.97);
}
button:focus-visible,
[role="button"]:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--fc-accent);
  outline-offset: 1px;
}
button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* --- fc-btn: Themed button class for toolbar/panel buttons --- */
.fc-btn {
  padding: 4px 10px;
  background: transparent;
  color: var(--fc-textMuted);
  border: 1px solid var(--fc-border);
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  line-height: 1;
  white-space: nowrap;
  user-select: none;
}
.fc-btn:hover {
  background: var(--fc-bgHover);
  color: var(--fc-text);
  border-color: var(--fc-textDim);
}
.fc-btn:active {
  background: var(--fc-bgActive);
}
.fc-btn.active {
  background: var(--fc-accent);
  color: var(--fc-accentText);
  border-color: var(--fc-accent);
}
.fc-btn.active:hover {
  filter: brightness(1.1);
}

/* --- fc-icon-btn: Small icon-only button --- */
.fc-icon-btn {
  padding: 4px;
  background: transparent;
  color: var(--fc-textDim);
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.fc-icon-btn:hover {
  background: var(--fc-bgHover);
  color: var(--fc-text);
  border-color: var(--fc-border);
}

/* --- Panel section headers --- */
.fc-panel-header {
  padding: 6px 12px;
  font-size: 11px;
  color: var(--fc-textDim);
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
  user-select: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition:
    background 0.12s ease,
    color 0.12s ease;
}
.fc-panel-header:hover {
  background: var(--fc-bgHover);
  color: var(--fc-textMuted);
}

/* --- Separator --- */
.fc-separator {
  width: 1px;
  height: 20px;
  background: var(--fc-border);
  margin: 0 4px;
  flex-shrink: 0;
}

/* --- Toolbar --- */
.fc-toolbar {
  padding: 6px 12px;
  background: var(--fc-bgHover);
  border-bottom: 1px solid var(--fc-border);
  display: flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}

/* --- Input fields --- */
input:not([type="range"]):not([type="checkbox"]):not([type="radio"]):not([type="color"]),
textarea,
select {
  background: var(--fc-bgInput);
  border: 1px solid var(--fc-border);
  border-radius: 4px;
  padding: 4px 6px;
  color: var(--fc-text);
  font-size: 12px;
  font-family: inherit;
}
input:not([type="range"]):not([type="checkbox"]):not([type="radio"]):not([type="color"]):focus,
textarea:focus,
select:focus {
  border-color: var(--fc-accent);
  box-shadow: 0 0 0 1px var(--fc-accent);
}

/* --- Tooltip-like subtle shadow for floating elements --- */
.fc-floating {
  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.3),
    0 1px 4px rgba(0, 0, 0, 0.2);
}

/* --- Animations --- */
@keyframes fc-fadein {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes fc-fadein-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes fc-slide-in-right {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}
@keyframes fc-slide-out-right {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(100%);
  }
}
@keyframes fc-pulse {
  0%,
  100% {
    opacity: 0.4;
  }
  50% {
    opacity: 1;
  }
}
@keyframes fc-shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}
@keyframes fc-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}
@keyframes fc-scale-in {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* --- Range inputs (sliders) --- */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--fc-border);
  border-radius: 2px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--fc-accent);
  cursor: pointer;
  border: 2px solid var(--fc-bgPanel);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition:
    transform 0.1s ease,
    box-shadow 0.1s ease;
}
input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.4);
}
input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--fc-accent);
  cursor: pointer;
  border: 2px solid var(--fc-bgPanel);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* --- Color input --- */
input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border: 1px solid var(--fc-border);
  border-radius: 4px;
  padding: 1px;
  cursor: pointer;
  background: transparent;
}
input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}
input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 3px;
}

/* --- Resize handle polish --- */
.fc-resize-handle {
  transition: background 0.15s ease;
}
.fc-resize-handle:hover {
  background: var(--fc-bgActive);
}

/* =====================================================================
   Documentation page styles
   ===================================================================== */

/* --- Layout shell --- */
.fc-docs-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--fc-bg);
}
.fc-docs-body {
  display: flex;
  flex: 1;
  padding-top: 56px;
}
.fc-docs-main {
  flex: 1;
  overflow-y: auto;
  height: calc(100vh - 56px);
}

/* --- Top nav --- */
.fc-docs-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: var(--fc-bg);
  border-bottom: 1px solid var(--fc-border);
  z-index: 100;
  backdrop-filter: blur(8px);
}
.fc-docs-nav-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--fc-text);
}
.fc-docs-nav-logo span:last-child {
  font-size: 16px;
  font-weight: 700;
  color: var(--fc-accent);
  letter-spacing: -0.02em;
}
.fc-docs-nav-links {
  display: flex;
  align-items: center;
  gap: 20px;
}
.fc-docs-nav-active {
  color: var(--fc-accent);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}
.fc-docs-nav-link {
  color: var(--fc-textMuted);
  text-decoration: none;
  font-size: 14px;
}
.fc-docs-nav-link:hover { color: var(--fc-text); }
.fc-docs-nav-cta {
  padding: 6px 16px;
  font-size: 14px;
  font-weight: 600;
  background: var(--fc-accent);
  color: var(--fc-accentText);
  border-radius: 6px;
  text-decoration: none;
  transition: opacity 0.15s;
}
.fc-docs-nav-cta:hover { opacity: 0.9; }

/* --- Search trigger in nav --- */
.fc-docs-search-trigger {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: var(--fc-bgSurface);
  border: 1px solid var(--fc-border);
  border-radius: 6px;
  color: var(--fc-textDim);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.fc-docs-search-trigger:hover {
  border-color: var(--fc-accent);
  color: var(--fc-textMuted);
}
.fc-docs-search-trigger kbd {
  margin-left: 4px;
  padding: 1px 5px;
  font-size: 11px;
  background: var(--fc-bgHover);
  border: 1px solid var(--fc-border);
  border-radius: 3px;
  font-family: var(--fc-mono, 'SF Mono', 'Fira Code', monospace);
  color: var(--fc-textDim);
}

/* --- Sidebar --- */
.fc-docs-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--fc-bgPanel);
  border-right: 1px solid var(--fc-border);
  padding: 20px 0;
  overflow-y: auto;
  height: calc(100vh - 56px);
  position: sticky;
  top: 56px;
}
.fc-docs-sidebar::-webkit-scrollbar { width: 4px; }
.fc-docs-sidebar::-webkit-scrollbar-track { background: transparent; }
.fc-docs-sidebar::-webkit-scrollbar-thumb { background: var(--fc-border); border-radius: 2px; }

.fc-docs-sidebar-group-title {
  padding: 12px 20px 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fc-textDim);
}
.fc-docs-sidebar-link {
  display: block;
  padding: 5px 20px 5px 24px;
  font-size: 13px;
  color: var(--fc-textMuted);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: color 0.1s, background 0.1s, border-color 0.1s;
}
.fc-docs-sidebar-link:hover {
  color: var(--fc-text);
  background: var(--fc-bgHover);
}
.fc-docs-sidebar-link.active {
  color: var(--fc-accent);
  border-left-color: var(--fc-accent);
  background: var(--fc-bgHover);
  font-weight: 600;
}

/* --- Index page --- */
.fc-docs-index {
  padding: 40px 48px 80px;
  max-width: 800px;
}
.fc-docs-index-hero {
  padding: 60px 0 40px;
  text-align: center;
}
.fc-docs-index-hero h1 {
  font-size: 32px;
  font-weight: 700;
  color: var(--fc-text);
  margin: 0 0 12px;
}
.fc-docs-index-hero p {
  font-size: 16px;
  color: var(--fc-textMuted);
  margin: 0 0 8px;
}
.fc-docs-index-hint {
  font-size: 13px;
  color: var(--fc-textDim);
}
.fc-docs-index-hint kbd {
  padding: 2px 6px;
  font-size: 12px;
  background: var(--fc-bgSurface);
  border: 1px solid var(--fc-border);
  border-radius: 4px;
  font-family: var(--fc-mono, monospace);
  color: var(--fc-accent);
}
.fc-docs-index-heading {
  font-size: 14px;
  font-weight: 600;
  color: var(--fc-textDim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 32px 0 12px;
}
.fc-docs-index-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 8px;
}
.fc-docs-index-card {
  display: block;
  padding: 16px 20px;
  background: var(--fc-bgSurface);
  border: 1px solid var(--fc-border);
  border-radius: 8px;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}
.fc-docs-index-card:hover {
  border-color: var(--fc-accent);
  background: var(--fc-bgHover);
}
.fc-docs-index-card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--fc-text);
  margin-bottom: 4px;
}
.fc-docs-index-card-desc {
  font-size: 13px;
  color: var(--fc-textMuted);
}

/* --- Doc content (markdown) --- */
.fc-docs-content {
  padding: 40px 48px 80px;
  max-width: 800px;
  margin: 0 auto;
  line-height: 1.7;
  color: var(--fc-text);
  font-size: 15px;
}
.fc-docs-content h1 {
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--fc-border);
  color: var(--fc-text);
}
.fc-docs-content h2 {
  font-size: 20px;
  font-weight: 600;
  margin: 36px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--fc-border);
  color: var(--fc-text);
}
.fc-docs-content h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 28px 0 8px;
  color: var(--fc-text);
}
.fc-docs-content h4 {
  font-size: 14px;
  font-weight: 600;
  margin: 20px 0 6px;
  color: var(--fc-accent);
}
.fc-docs-content p {
  margin: 0 0 12px;
  color: var(--fc-text);
}
.fc-docs-content ul, .fc-docs-content ol {
  padding-left: 24px;
  margin: 0 0 12px;
}
.fc-docs-content li {
  margin-bottom: 4px;
}
.fc-docs-content li > ul, .fc-docs-content li > ol {
  margin-top: 4px;
  margin-bottom: 0;
}
.fc-docs-content a {
  color: var(--fc-accent);
  text-decoration: none;
}
.fc-docs-content a:hover {
  text-decoration: underline;
}
.fc-docs-content strong {
  font-weight: 600;
  color: var(--fc-text);
}
.fc-docs-content hr {
  border: none;
  border-top: 1px solid var(--fc-border);
  margin: 24px 0;
}
.fc-docs-content img {
  max-width: 100%;
  border-radius: 8px;
}

/* Anchor links on headings */
.fc-docs-anchor {
  opacity: 0;
  margin-left: 8px;
  color: var(--fc-textMuted);
  text-decoration: none;
  font-weight: 400;
  font-size: 0.8em;
  transition: opacity 0.15s;
}
.fc-docs-content h1:hover .fc-docs-anchor,
.fc-docs-content h2:hover .fc-docs-anchor,
.fc-docs-content h3:hover .fc-docs-anchor,
.fc-docs-content h4:hover .fc-docs-anchor {
  opacity: 1;
}

/* Scroll-to highlight */
.fc-docs-highlight {
  animation: fc-docs-flash 1.5s ease-out;
}
@keyframes fc-docs-flash {
  0% { background: var(--fc-bgActive); }
  100% { background: transparent; }
}

/* Code blocks */
.fc-docs-code {
  background: var(--fc-bgPanel);
  border: 1px solid var(--fc-border);
  border-radius: 8px;
  padding: 16px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.5;
  margin: 0 0 16px;
  font-family: var(--fc-mono, 'JetBrains Mono', 'Fira Code', 'SF Mono', monospace);
}
.fc-docs-code code {
  background: none;
  padding: 0;
  border: none;
  font-size: 13px;
  color: var(--fc-text);
}

/* Inline code — cyan tint for visibility */
.fc-docs-inline-code {
  background: var(--fc-bgSurface);
  border: 1px solid var(--fc-border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.9em;
  font-family: var(--fc-mono, 'JetBrains Mono', 'Fira Code', 'SF Mono', monospace);
  color: var(--fc-accent);
}

/* Blockquotes */
.fc-docs-blockquote {
  border-left: 3px solid var(--fc-accent);
  margin: 0 0 12px;
  padding: 8px 16px;
  background: var(--fc-bgSurface);
  border-radius: 0 4px 4px 0;
  color: var(--fc-textMuted);
}
.fc-docs-blockquote p {
  margin: 0;
}

/* Tables */
.fc-docs-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 16px;
  font-size: 13px;
}
.fc-docs-table th,
.fc-docs-table td {
  padding: 8px 12px;
  border: 1px solid var(--fc-border);
  text-align: left;
}
.fc-docs-table th {
  background: var(--fc-bgSurface);
  font-weight: 600;
  color: var(--fc-text);
}
.fc-docs-table td {
  color: var(--fc-textMuted);
}

/* Details/summary (collapsible sections in API docs) */
.fc-docs-content details {
  margin: 0 0 12px;
  border: 1px solid var(--fc-border);
  border-radius: 8px;
  overflow: hidden;
}
.fc-docs-content details summary {
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 500;
  color: var(--fc-textMuted);
  background: var(--fc-bgSurface);
  transition: color 0.1s;
}
.fc-docs-content details summary:hover {
  color: var(--fc-text);
}
.fc-docs-content details[open] summary {
  border-bottom: 1px solid var(--fc-border);
  color: var(--fc-text);
}
.fc-docs-content details > :not(summary) {
  padding: 0 16px;
}
.fc-docs-content details > pre {
  margin: 12px 0;
  border: none;
  border-radius: 0;
}

/* --- Highlight.js token colors (scoped to docs) ---
   Uses theme-aware CSS variables so tokens adapt to any app theme.
   Default palette matches Tokyo Night. */
.fc-docs-content .hljs-keyword,
.fc-docs-content .hljs-tag { color: var(--fc-accent); }
.fc-docs-content .hljs-string,
.fc-docs-content .hljs-template-variable { color: var(--fc-success, #9ece6a); }
.fc-docs-content .hljs-number,
.fc-docs-content .hljs-literal { color: var(--fc-warning, #ff9e64); }
.fc-docs-content .hljs-type,
.fc-docs-content .hljs-title.class_,
.fc-docs-content .hljs-built_in { color: var(--fc-warning, #e0af68); }
.fc-docs-content .hljs-comment { color: var(--fc-textDim); font-style: italic; }
.fc-docs-content .hljs-attr,
.fc-docs-content .hljs-attribute { color: var(--fc-accent); }
.fc-docs-content .hljs-params { color: var(--fc-text); }
.fc-docs-content .hljs-title.function_ { color: var(--fc-accent); }
.fc-docs-content .hljs-punctuation { color: var(--fc-textMuted); }
.fc-docs-content .hljs-property { color: var(--fc-text); }
.fc-docs-content .hljs-variable { color: var(--fc-text); }
.fc-docs-content .hljs-regexp { color: var(--fc-error, #f7768e); }
.fc-docs-content .hljs-meta { color: var(--fc-textDim); }
.fc-docs-content .hljs-selector-class { color: var(--fc-accent); }

/* --- Search overlay --- */
.fc-docs-search-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: min(20vh, 160px);
}
.fc-docs-search-modal {
  width: 560px;
  max-width: calc(100vw - 32px);
  background: var(--fc-bgPanel);
  border: 1px solid var(--fc-border);
  border-radius: 12px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}
.fc-docs-search-input-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--fc-border);
}
.fc-docs-search-input-wrap input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-size: 16px;
  font-family: inherit;
  color: var(--fc-text);
}
.fc-docs-search-input-wrap input::placeholder {
  color: var(--fc-textDim);
}
.fc-docs-search-input-wrap kbd {
  padding: 2px 6px;
  font-size: 11px;
  background: var(--fc-bgSurface);
  border: 1px solid var(--fc-border);
  border-radius: 4px;
  color: var(--fc-textDim);
  font-family: var(--fc-mono, monospace);
}
.fc-docs-search-results {
  max-height: 400px;
  overflow-y: auto;
}
.fc-docs-search-results::-webkit-scrollbar { width: 4px; }
.fc-docs-search-results::-webkit-scrollbar-thumb { background: var(--fc-border); border-radius: 2px; }

.fc-docs-search-result {
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--fc-border);
  transition: background 0.08s;
}
.fc-docs-search-result:last-child { border-bottom: none; }
.fc-docs-search-result:hover,
.fc-docs-search-result.selected {
  background: var(--fc-bgHover);
}
.fc-docs-search-result.selected {
  background: var(--fc-bgActive);
}
.fc-docs-search-result-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--fc-text);
}
.fc-docs-search-result-category {
  font-size: 12px;
  color: var(--fc-textDim);
  margin-top: 2px;
}
.fc-docs-search-result-snippet {
  font-size: 12px;
  color: var(--fc-textMuted);
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fc-docs-search-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--fc-textDim);
  font-size: 14px;
}
.fc-docs-search-footer {
  display: flex;
  gap: 16px;
  padding: 8px 16px;
  border-top: 1px solid var(--fc-border);
  font-size: 12px;
  color: var(--fc-textDim);
}
.fc-docs-search-footer kbd {
  padding: 1px 5px;
  font-size: 11px;
  background: var(--fc-bgSurface);
  border: 1px solid var(--fc-border);
  border-radius: 3px;
  font-family: var(--fc-mono, monospace);
  color: var(--fc-textMuted);
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .fc-docs-sidebar { display: none; }
  .fc-docs-content { padding: 20px 16px 60px; }
  .fc-docs-index { padding: 20px 16px 60px; }
  .fc-docs-index-grid { grid-template-columns: 1fr; }
}
