/* ─── APP SHELL ──────────────────────────────────────────────── */
html, body { height: 100%; overflow: hidden; }

/* Subtle grid background */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px);
  background-size: 52px 52px;
}

/* ─── APP NAV ────────────────────────────────────────────────── */
.app-nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  height: 50px; display: flex; align-items: center;
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,.92);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.app-nav-inner {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 0 14px;
}
.app-nav-left  { display: flex; align-items: center; gap: 14px; }
.app-nav-right { display: flex; align-items: center; gap: 6px; }

.app-nav-logo {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-mono); font-weight: 700; font-size: .85rem;
  color: var(--text-primary); letter-spacing: -.01em;
  transition: opacity var(--t);
}
.app-nav-logo:hover { opacity: .7; }
.logo-mark {
  display: flex; align-items: center; justify-content: center;
  width: 24px; height: 24px;
  background: var(--text-primary); color: #000;
  font-size: .56rem; font-weight: 900; border-radius: 3px;
}

.app-nav-sep { width: 1px; height: 18px; background: var(--border); }

.app-nav-filename {
  font-family: var(--font-mono); font-size: .73rem; color: var(--text-muted);
  max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.app-nav-status { display: flex; align-items: center; gap: 6px; }
.status-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-dim); transition: background var(--tm);
}
.status-dot.ok   { background: var(--ok); }
.status-dot.warn { background: var(--warn); }
.status-dot.err  { background: var(--err); animation: pulse 1.4s ease-in-out infinite; }
.status-dot.busy { background: var(--info); animation: pulse .9s ease-in-out infinite; }
#nav-status-text { font-family: var(--font-mono); font-size: .68rem; color: var(--text-muted); }

/* ─── CAP BANNER ─────────────────────────────────────────────── */
.cap-banner {
  position: fixed; top: 50px; left: 0; right: 0; z-index: 40;
  padding: 7px 14px; font-size: .74rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
  display: flex; align-items: center; gap: 9px;
  transform: translateY(-110%); transition: transform var(--tm);
}
.cap-banner.show { transform: translateY(0); }
.cap-banner.warn-banner { border-bottom-color: rgba(251,191,36,.25); color: var(--warn); background: rgba(251,191,36,.05); }
.cap-banner.err-banner  { border-bottom-color: rgba(248,113,113,.25); color: var(--err);  background: rgba(248,113,113,.05); }
.cap-banner-close { margin-left: auto; cursor: pointer; opacity: .5; transition: opacity var(--t); line-height: 0; }
.cap-banner-close:hover { opacity: 1; }

/* ─── LAYOUT ──────────────────────────────────────────────────── */
.app-layout {
  display: grid;
  grid-template-columns: 1fr 272px 1fr;
  height: calc(100vh - 50px);
  margin-top: 50px;
  overflow: hidden;
  position: relative; z-index: 1;
}

/* ─── PANEL COMMON ────────────────────────────────────────────── */
.app-panel {
  display: flex; flex-direction: column;
  border-right: 1px solid var(--border);
  overflow: hidden;
  background: var(--bg-base);
}
.app-panel:last-child { border-right: none; }

.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px; height: 40px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel); flex-shrink: 0;
}
.panel-title {
  font-family: var(--font-mono); font-size: .64rem; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase; color: var(--text-dim);
  display: flex; align-items: center; gap: 7px;
}
.panel-actions { display: flex; align-items: center; gap: 3px; }
.panel-body { flex: 1; overflow-y: auto; overflow-x: hidden; position: relative; }

/* ─── INPUT TABS ─────────────────────────────────────────────── */
.input-tabs {
  display: flex; border-bottom: 1px solid var(--border);
  background: var(--bg-panel); flex-shrink: 0;
}
.input-tab {
  display: flex; align-items: center; gap: 6px;
  padding: 9px 14px; font-family: var(--font-mono);
  font-size: .72rem; font-weight: 600; color: var(--text-dim);
  border: none; background: transparent;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color var(--t), border-color var(--t);
  position: relative; bottom: -1px; letter-spacing: .06em; text-transform: uppercase;
}
.input-tab:hover { color: var(--text-secondary); }
.input-tab.active { color: var(--text-primary); border-bottom-color: var(--text-primary); }

/* ─── DROP ZONE ──────────────────────────────────────────────── */
.drop-zone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 40px 20px; min-height: 180px;
  border: 1px dashed var(--border-mid); border-radius: var(--radius-lg);
  margin: 12px; cursor: pointer;
  transition: border-color var(--tm), background var(--tm);
  position: relative;
}
.drop-zone input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--border-hi); background: var(--bg-hover);
}
.drop-zone.drag-over { animation: borderGlow 1s ease-in-out infinite; }
.drop-zone-icon { color: var(--text-dim); }
.drop-zone-title { font-size: .85rem; font-weight: 600; color: var(--text-secondary); }
.drop-zone-sub   { font-size: .74rem; color: var(--text-muted); text-align: center; }
.drop-zone .btn  { position: relative; z-index: 1; pointer-events: all; }

/* ─── FILE INFO ──────────────────────────────────────────────── */
.file-info {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px; border-bottom: 1px solid var(--border);
  background: var(--bg-panel); font-size: .72rem; flex-shrink: 0;
  animation: slideUp var(--tm) both;
  font-family: var(--font-mono);
}
.file-info-name { color: var(--text-secondary); font-weight: 600; }
.file-info-sep  { color: var(--text-dim); }
.file-info-meta { color: var(--text-muted); }
.file-info-clear { margin-left: auto; }

/* ─── PASTE ──────────────────────────────────────────────────── */
.paste-area {
  width: 100%; height: 100%;
  background: transparent; color: var(--text-primary);
  border: none; outline: none; resize: none;
  font-family: var(--font-mono); font-size: .79rem; line-height: 1.75;
  padding: 12px;
  caret-color: var(--text-primary);
}
.paste-area::placeholder { color: var(--text-dim); }

/* ─── CODE VIEWER ────────────────────────────────────────────── */
.code-viewer {
  width: 100%; height: 100%;
  display: flex; flex-direction: column; overflow: hidden;
}
.viewer-toolbar {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 8px; border-bottom: 1px solid var(--border);
  background: var(--bg-panel); flex-shrink: 0;
}
.viewer-search {
  flex: 1; display: flex; align-items: center; gap: 6px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 4px 9px;
  transition: border-color var(--t);
}
.viewer-search:focus-within { border-color: var(--border-hi); }
.viewer-search input {
  background: transparent; border: none; outline: none;
  color: var(--text-primary); font-family: var(--font-mono); font-size: .74rem;
  width: 100%;
}
.viewer-search input::placeholder { color: var(--text-dim); }
.viewer-search svg { color: var(--text-dim); }
.viewer-matches { font-family: var(--font-mono); font-size: .65rem; color: var(--text-muted); white-space: nowrap; }

.code-scroll-area  { flex: 1; overflow: auto; position: relative; }
.code-inner        { display: flex; position: relative; min-height: 100%; }
.line-numbers {
  padding: 8px 0; background: var(--bg-panel);
  border-right: 1px solid var(--border);
  user-select: none; flex-shrink: 0; width: 52px; min-width: 52px; text-align: right;
}
.line-num {
  display: block; height: 20px;
  padding-right: 9px; font-family: var(--font-mono); font-size: .7rem; line-height: 20px;
  color: var(--text-dim);
}
.line-num.highlight { color: var(--text-muted); }
.code-lines { flex: 1; padding: 8px 0 8px 11px; }
.code-line {
  display: block; height: 20px; line-height: 20px;
  font-family: var(--font-mono); font-size: .77rem;
  white-space: pre; color: var(--text-secondary);
  transition: background var(--t);
}
.code-line:hover { background: rgba(255,255,255,.012); }
.code-line.search-match { background: rgba(251,191,36,.07); }
.code-empty {
  display: flex; align-items: center; justify-content: center;
  height: 100%; font-family: var(--font-mono); font-size: .75rem;
  color: var(--text-dim); flex-direction: column; gap: 8px; padding: 28px; text-align: center;
}

/* Syntax */
.syn-keyword  { color: #a78bfa; }
.syn-string   { color: #86efac; }
.syn-comment  { color: #404040; font-style: italic; }
.syn-number   { color: #fca57a; }
.syn-builtin  { color: #67d9f5; }

/* ─── CONFIG PANEL ────────────────────────────────────────────── */
.config-scroll { overflow-y: auto; padding: 10px; }
.config-section { margin-bottom: 16px; }
.config-section-label {
  font-family: var(--font-mono); font-size: .58rem; font-weight: 800;
  letter-spacing: .18em; text-transform: uppercase; color: var(--text-dim);
  padding: 0 4px; margin-bottom: 5px;
}
.config-item {
  display: flex; flex-direction: column; gap: 4px;
  padding: 9px 11px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--bg-panel);
  margin-bottom: 3px; transition: border-color var(--t);
}
.config-item:hover { border-color: var(--border-mid); }
.config-item-top {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
}
.config-item-name {
  font-family: var(--font-mono); font-size: .76rem; font-weight: 600; color: var(--text-secondary);
}
.config-item-flag { font-family: var(--font-mono); font-size: .62rem; color: var(--text-dim); }
.config-item-desc { font-size: .7rem; color: var(--text-muted); line-height: 1.5; }
.config-item-control { display: flex; align-items: center; gap: 8px; margin-top: 3px; }

/* Toggle */
.toggle { position: relative; width: 32px; height: 17px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-track {
  position: absolute; inset: 0; border-radius: 8px;
  background: var(--bg-active); border: 1px solid var(--border-mid);
  cursor: pointer; transition: background var(--t), border-color var(--t);
}
.toggle-thumb {
  position: absolute; top: 2px; left: 2px;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--text-dim);
  transition: transform var(--t), background var(--t);
}
.toggle input:checked + .toggle-track { background: rgba(255,255,255,.12); border-color: var(--border-hi); }
.toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(15px); background: var(--text-primary); }
.toggle-label { font-family: var(--font-mono); font-size: .72rem; color: var(--text-muted); }

/* Number inputs */
.num-input {
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-family: var(--font-mono); font-size: .79rem;
  padding: 4px 8px; width: 68px; text-align: right;
  transition: border-color var(--t);
}
.num-input:focus { outline: none; border-color: var(--border-hi); }

/* ─── CONFIG FOOTER ──────────────────────────────────────────── */
.config-footer {
  padding: 9px 10px; border-top: 1px solid var(--border);
  flex-shrink: 0; display: flex; flex-direction: column; gap: 5px;
}
.btn-run {
  width: 100%; height: 40px; font-size: .84rem; font-weight: 700;
  border-radius: var(--radius); justify-content: center; letter-spacing: .02em;
}
.btn-run .spinner { animation: spin .7s linear infinite; }

/* ─── STAGES ─────────────────────────────────────────────────── */
.stages-list {
  padding: 8px 10px;
  display: flex; flex-direction: column; gap: 2px;
  flex-shrink: 0; border-top: 1px solid var(--border);
  max-height: 210px; overflow-y: auto;
}
.stage-item {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 9px; border-radius: var(--radius-sm);
  font-family: var(--font-mono); font-size: .7rem;
  animation: slideIn var(--tm) both;
  transition: background var(--t);
}
.stage-item:hover { background: var(--bg-hover); }
.stage-item-icon { flex-shrink: 0; width: 14px; height: 14px; }
.stage-item.pending .stage-item-icon { color: var(--text-dim); }
.stage-item.running .stage-item-icon { color: var(--info); animation: pulse 1s ease-in-out infinite; }
.stage-item.done    .stage-item-icon { color: var(--ok); }
.stage-item.error   .stage-item-icon { color: var(--err); }
.stage-item-name { flex: 1; color: var(--text-secondary); }
.stage-item.running .stage-item-name { color: var(--text-primary); }
.stage-item.done    .stage-item-name { color: var(--text-muted); }
.stage-item.error   .stage-item-name { color: var(--err); }
.stage-item-dur { color: var(--text-dim); font-size: .62rem; }

/* ─── OUTPUT ─────────────────────────────────────────────────── */
.output-stats {
  display: flex; flex-wrap: wrap; gap: 12px;
  padding: 7px 12px; border-bottom: 1px solid var(--border);
  font-family: var(--font-mono); font-size: .67rem; color: var(--text-muted);
  flex-shrink: 0; background: var(--bg-panel);
}
.stat { display: flex; align-items: center; gap: 5px; }
.stat-val { color: var(--text-secondary); }

.output-empty {
  display: flex; align-items: center; justify-content: center;
  height: 100%; flex-direction: column; gap: 10px;
  font-family: var(--font-mono); font-size: .75rem; color: var(--text-dim);
  text-align: center; padding: 24px;
}

/* ─── ERROR ──────────────────────────────────────────────────── */
.error-block {
  margin: 12px; padding: 12px 14px;
  background: rgba(248,113,113,.04); border: 1px solid rgba(248,113,113,.2);
  border-radius: var(--radius); animation: slideUp var(--tm) both;
}
.error-block-title {
  font-family: var(--font-mono); font-size: .75rem; font-weight: 700; color: var(--err);
  display: flex; align-items: center; gap: 6px; margin-bottom: 7px;
}
.error-block-msg {
  font-family: var(--font-mono); font-size: .72rem;
  color: var(--text-secondary); line-height: 1.6; white-space: pre-wrap;
}
.error-block-hint {
  margin-top: 9px; font-size: .72rem; color: var(--text-muted); line-height: 1.6;
}
.error-block-hint code {
  background: var(--bg-input); padding: 1px 5px;
  border-radius: 3px; border: 1px solid var(--border); font-size: .7rem;
  font-family: var(--font-mono);
}

/* ─── DETECTION RESULT ────────────────────────────────────────── */
.detect-result {
  margin: 12px; padding: 12px 14px;
  border-radius: var(--radius); border: 1px solid var(--border);
  animation: slideUp var(--tm) both;
}
.detect-result.is-luraph  { background: rgba(74,222,128,.04); border-color: rgba(74,222,128,.2); }
.detect-result.not-luraph { background: var(--bg-panel); border-color: var(--border); }
.detect-title {
  font-family: var(--font-mono); font-size: .78rem; font-weight: 700;
  display: flex; align-items: center; gap: 7px; margin-bottom: 8px;
}
.detect-patterns { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; }
.detect-pattern {
  display: flex; align-items: center; gap: 7px;
  font-family: var(--font-mono); font-size: .68rem; color: var(--text-muted);
}
.detect-pattern.found   { color: var(--ok); }
.detect-pattern.missing { color: var(--text-dim); }

/* ─── MODAL ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.8);
  display: flex; align-items: center; justify-content: center;
  padding: 16px; animation: fadeIn var(--t) both;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--bg-panel); border: 1px solid var(--border-mid);
  border-radius: var(--radius-lg); padding: 26px;
  width: 100%; max-width: 460px;
  animation: slideUp var(--tm) both; box-shadow: var(--shadow-lg);
}
.modal-title { font-size: .95rem; font-weight: 700; margin-bottom: 6px; }
.modal-desc  { font-size: .78rem; color: var(--text-muted); margin-bottom: 18px; line-height: 1.6; }
.modal-field { margin-bottom: 14px; }
.modal-label { font-family: var(--font-mono); font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 6px; display: block; }
.modal-input {
  width: 100%; background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-family: var(--font-mono); font-size: .82rem; padding: 9px 12px;
  transition: border-color var(--t);
}
.modal-input:focus { outline: none; border-color: var(--border-hi); }
.modal-hint {
  font-family: var(--font-mono); font-size: .68rem; color: var(--text-muted);
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px; margin-top: 7px; line-height: 1.7;
}
.modal-hint code { font-size: .67rem; background: var(--bg-active); padding: 1px 5px; border-radius: 2px; border: 1px solid var(--border-mid); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* ─── ELAPSED ─────────────────────────────────────────────────── */
.elapsed { font-family: var(--font-mono); font-size: .66rem; color: var(--text-muted); min-width: 46px; text-align: right; }

/* ─── MOBILE ──────────────────────────────────────────────────── */
@media (max-width: 900px) {
  html, body { overflow: auto; }
  .app-layout { display: flex; flex-direction: column; height: auto; overflow: visible; margin-top: 50px; }
  .app-panel  { border-right: none; border-bottom: 1px solid var(--border); height: auto; min-height: 340px; overflow: visible; }
  .panel-body { overflow: visible; min-height: 240px; }
  .code-viewer { height: 300px; }
  .code-scroll-area { overflow: auto; }
  .stages-list { max-height: none; }
}
