/* ── Variables (Midnight Cockpit) ───────────────────────────────────────── */
:root {
  --bg:        #0a0e14;
  --surface:   #1a1f29;
  --border:    #2d3640;
  --accent:    #e6b450;
  --text:      #b3b1ad;
  --text-dim:  #5c6370;
  --green:     #91b362;
  --red:       #ea6c73;
  --yellow:    #f9af4f;
}

/* ── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 14px;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

/* ── Login Screen ───────────────────────────────────────────────────────── */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100dvh;
}
.login-screen[hidden] { display: none !important; }

.login-card {
  width: min(340px, 92vw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 28px 24px;
}

.login-title {
  font-size: 15px;
  color: var(--accent);
  margin-bottom: 24px;
}

.login-cursor {
  display: inline-block;
  animation: blink 1s step-end infinite;
  color: var(--accent);
}

@keyframes blink { 50% { opacity: 0; } }

.login-form { display: flex; flex-direction: column; gap: 14px; }

.login-field {
  display: flex;
  align-items: center;
  gap: 8px;
}

.login-field label {
  color: var(--text-dim);
  min-width: 80px;
  font-size: 13px;
}

.login-field input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 2px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  padding: 7px 10px;
  outline: none;
}

.login-field input:focus { border-color: var(--accent); }

.login-btn {
  background: transparent;
  border: 1px solid var(--accent);
  border-radius: 2px;
  color: var(--accent);
  font-family: inherit;
  font-size: 13px;
  padding: 9px;
  cursor: pointer;
  transition: background 0.15s;
  margin-top: 4px;
}

.login-btn:hover, .login-btn:active { background: rgba(230,180,80,0.12); }

.login-error {
  color: var(--red);
  font-size: 12px;
  text-align: center;
}

/* ── App Shell ──────────────────────────────────────────────────────────── */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}
.app-shell[hidden] { display: none !important; }

/* ── Explorer Bar ───────────────────────────────────────────────────────── */
.explorer-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.explorer-header {
  display: flex;
  align-items: center;
  height: 40px;
  padding: 0 10px;
  gap: 8px;
}

.breadcrumb {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  font-size: 12px;
  white-space: nowrap;
}

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

.breadcrumb-seg {
  color: var(--text-dim);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 2px;
}

.breadcrumb-seg:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.breadcrumb-seg.active { color: var(--accent); }

.breadcrumb-sep { color: var(--accent); opacity: 0.5; user-select: none; }

.explorer-actions { display: flex; gap: 4px; }

.icon-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  padding: 4px 6px;
  border-radius: 2px;
  line-height: 1;
}

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

.file-list {
  max-height: 45dvh;
  overflow-y: auto;
  border-top: 1px solid var(--border);
  animation: slide-down 0.15s ease;
}

@keyframes slide-down { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.file-entry {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  cursor: pointer;
  font-size: 12px;
  border-bottom: 1px solid rgba(45,54,64,0.4);
}

.file-entry:hover { background: rgba(255,255,255,0.04); box-shadow: inset 0 0 0 1px var(--accent); }
.file-entry:active { background: rgba(230,180,80,0.08); }

.file-icon { font-size: 14px; flex-shrink: 0; }

.file-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.file-name.hidden { color: var(--text-dim); }

.file-size { color: var(--text-dim); font-size: 11px; flex-shrink: 0; }

/* File action menu */
.file-menu {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 0;
  z-index: 100;
  min-width: 160px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}

.file-menu-item {
  display: block;
  padding: 9px 14px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text);
}

.file-menu-item:hover { background: rgba(255,255,255,0.06); color: var(--accent); }

/* ── Terminal wrap ──────────────────────────────────────────────────────── */
.terminal-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 0;
  padding-bottom: var(--quickkeys-h, 0px);
}

.terminal-container {
  width: 100%;
  height: 100%;
  padding: 4px;
}

/* ── Connection indicator ───────────────────────────────────────────────── */
.conn-indicator {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  z-index: 10;
}

.conn-indicator.connected { background: var(--green); animation: pulse 2s ease-in-out infinite; }
.conn-indicator.connecting { background: var(--yellow); }
.conn-indicator.disconnected { background: var(--red); }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(145,179,98,0.6); }
  50% { box-shadow: 0 0 0 4px rgba(145,179,98,0); }
}

/* ── Quick-key toolbar ──────────────────────────────────────────────────── */
.quickkeys {
  background: rgba(26,31,41,0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  padding: 4px 4px max(6px, env(safe-area-inset-bottom));
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
}

.quickkeys-row {
  display: flex;
  gap: 3px;
  overflow-x: auto;
  scrollbar-width: none;
}

.quickkeys-row::-webkit-scrollbar { display: none; }

.qk {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text);
  font-family: inherit;
  font-size: 11px;
  padding: 6px 10px;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
  transition: background 0.1s;
  -webkit-user-select: none;
  user-select: none;
}

.qk:active { background: rgba(230,180,80,0.15); border-color: var(--accent); }
.qk.qk-ctrl.ctrl-active   { background: rgba(230,180,80,0.2); border-color: var(--accent); color: var(--accent); }
.qk.qk-shift.shift-active { background: rgba(83,189,250,0.2); border-color: #53bdfa; color: #53bdfa; }
.qk[data-action="copy"],
.qk[data-action="paste"]  { border-color: #4a9; color: #4a9; font-weight: 600; }

/* ── Clipboard modal ────────────────────────────────────────────────────── */
.clip-modal {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,0.65);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.clip-modal[hidden] { display: none; }
.clip-modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 100%; max-width: 420px;
  padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.clip-modal-title { color: var(--accent); font-size: 13px; font-weight: 600; }
.clip-modal-ta {
  width: 100%; box-sizing: border-box;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 4px;
  font-family: inherit; font-size: 12px;
  padding: 8px; resize: none;
  min-height: 90px;
}
.clip-modal-actions { display: flex; gap: 8px; justify-content: flex-end; }
.clip-modal-btn {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 4px;
  font-family: inherit; font-size: 12px;
  padding: 7px 16px; cursor: pointer;
}
.clip-modal-ok { border-color: #4a9; color: #4a9; font-weight: 600; }

/* ── Loading overlay ────────────────────────────────────────────────────── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--accent);
  font-size: 18px;
}

/* ── Responsive / landscape ─────────────────────────────────────────────── */
@media (orientation: landscape) and (max-height: 480px) {
  .file-list { max-height: 35dvh; }
  .quickkeys { display: none; }
}
