:root {
  --bg-core: #0a0a0c;
  --bg-bar: #111216;
  --bg-keybar: #14161b;
  --bg-key-active: #1f232b;
  --border-raw: #262933;
  --fg-main: #e2e8f0;
  --fg-dim: #7f849c;
  --arch-blue: #1793d1;
  --arch-cyan: #89dceb;
  --term-green: #a6e3a1;
  --term-red: #f38ba8;
  --term-yellow: #f9e2af;
  --term-magenta: #cba6f7;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Source Code Pro', 'Courier New', Courier, monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border-radius: 0 !important;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-core);
  color: var(--fg-main);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

#app-viewport {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100dvh;
  background-color: var(--bg-core);
  overflow: hidden;
}

/* --- BARRE DE STATUT i3status --- */
#i3status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 24px;
  min-height: 24px;
  padding: 0 8px;
  background-color: var(--bg-bar);
  border-bottom: 1px solid var(--border-raw);
  font-size: 12px;
  user-select: none;
  white-space: nowrap;
  overflow-x: auto;
}

#i3status-bar::-webkit-scrollbar {
  display: none;
}

.status-left, .status-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ws-badge {
  padding: 1px 6px;
  background-color: var(--bg-core);
  color: var(--fg-dim);
  border: 1px solid var(--border-raw);
  font-weight: 700;
}

.ws-badge.active {
  background-color: var(--arch-blue);
  color: var(--bg-core);
  border-color: var(--arch-blue);
}

.status-sep {
  color: var(--border-raw);
}

/* --- ESPACE DE TRAVAIL / TILING --- */
#workspace-container {
  flex: 1;
  display: flex;
  flex-direction: row;
  width: 100%;
  min-height: 0;
  overflow: hidden;
}

#terminal-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 10px 12px 6px 12px;
  overflow-y: auto;
  overflow-x: hidden;
  cursor: text;
}

/* Scrollbar ultra-fine */
#terminal-pane::-webkit-scrollbar {
  width: 3px;
}

#terminal-pane::-webkit-scrollbar-track {
  background: var(--bg-core);
}

#terminal-pane::-webkit-scrollbar-thumb {
  background: var(--border-raw);
}

#terminal-output {
  display: flex;
  flex-direction: column;
  gap: 4px;
  word-break: break-word;
}

.output-line {
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* --- LIGNE D'INPUT & CURSEUR BLOC --- */
#input-row {
  display: flex;
  align-items: flex-start;
  flex-wrap: nowrap;
  margin-top: 4px;
  padding-bottom: 4px;
  position: relative;
}

#prompt-label {
  white-space: pre;
  margin-right: 8px;
  user-select: none;
  flex-shrink: 0;
  font-weight: 700;
}

.p-bracket { color: var(--fg-dim); }
.p-user { color: var(--term-green); }
.p-at { color: var(--fg-dim); }
.p-host { color: var(--arch-blue); }
.p-dir { color: var(--arch-cyan); }

#input-wrapper {
  position: relative;
  flex: 1;
  min-height: 20px;
  white-space: pre-wrap;
  word-break: break-all;
}

#input-mirror-before,
#input-mirror-after {
  color: var(--fg-main);
}

#cursor-block {
  display: inline-block;
  color: var(--arch-blue);
  animation: tty-blink 1s steps(1, end) infinite;
  font-weight: 700;
}

@keyframes tty-blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

#cmd-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  border: none;
  outline: none;
  font-family: var(--font-mono);
  font-size: 16px; /* Évite le zoom automatique iOS/Android au focus */
}

/* --- FENÊTRE IFRAME TILING --- */
#iframe-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-left: 2px solid var(--arch-blue);
  background-color: var(--bg-core);
  min-width: 0;
  min-height: 0;
}

#iframe-titlebar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 26px;
  padding: 0 8px;
  background-color: var(--bg-bar);
  border-bottom: 1px solid var(--arch-blue);
  font-size: 12px;
}

#iframe-title {
  color: var(--arch-cyan);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.iframe-controls {
  display: flex;
  gap: 6px;
}

.frame-btn {
  background: var(--bg-core);
  color: var(--fg-main);
  border: 1px solid var(--border-raw);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 1px 6px;
  cursor: pointer;
}

.frame-btn-danger {
  color: var(--term-red);
  border-color: var(--term-red);
}

#web-iframe {
  flex: 1;
  width: 100%;
  height: 100%;
  border: none;
  background-color: #ffffff;
}

/* --- BARRE TACTILE TABLETTE --- */
#touch-keybar {
  display: flex;
  align-items: center;
  height: 36px;
  min-height: 36px;
  background-color: var(--bg-keybar);
  border-top: 1px solid var(--border-raw);
  overflow-x: auto;
  user-select: none;
}

#touch-keybar::-webkit-scrollbar {
  display: none;
}

.touch-key {
  flex: 1 0 auto;
  height: 100%;
  padding: 0 14px;
  background: transparent;
  color: var(--fg-main);
  border: none;
  border-right: 1px solid var(--border-raw);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.touch-key:active {
  background-color: var(--arch-blue);
  color: var(--bg-core);
}

/* --- CLASSES SYNTAXIQUES & COMPOSANTS CLI --- */
.hidden {
  display: none !important;
}

.arch-blue { color: var(--arch-blue); }
.txt-cyan { color: var(--arch-cyan); }
.txt-green { color: var(--term-green); }
.txt-red { color: var(--term-red); }
.txt-yellow { color: var(--term-yellow); }
.txt-magenta { color: var(--term-magenta); }
.txt-dim { color: var(--fg-dim); }
.txt-bold { font-weight: 700; }

/* Formatage Neofetch */
.neofetch-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: flex-start;
  margin: 6px 0;
}

.neofetch-ascii {
  color: var(--arch-blue);
  font-weight: 700;
  line-height: 1.18;
  white-space: pre;
  user-select: none;
}

.neofetch-info {
  display: flex;
  flex-direction: column;
  white-space: pre-wrap;
}

.color-blocks {
  display: inline-flex;
  margin-top: 6px;
}

.c-block {
  display: inline-block;
  width: 18px;
  height: 14px;
}

/* Formatage Man Pages */
.man-page {
  border-left: 2px solid var(--arch-blue);
  padding-left: 10px;
  margin: 6px 0;
}

.man-header {
  display: flex;
  justify-content: space-between;
  color: var(--arch-cyan);
  font-weight: 700;
  border-bottom: 1px solid var(--border-raw);
  padding-bottom: 2px;
  margin-bottom: 6px;
}

.man-sec-title {
  color: var(--arch-blue);
  font-weight: 700;
  margin-top: 8px;
}

.man-indent {
  padding-left: 16px;
}

/* Tableaux ASCII / Aliases */
.cli-table {
  width: 100%;
  border-collapse: collapse;
  margin: 6px 0;
  font-size: 13px;
}

.cli-table th,
.cli-table td {
  text-align: left;
  padding: 3px 8px;
  border-bottom: 1px solid var(--border-raw);
  vertical-align: top;
}

.cli-table th {
  color: var(--arch-blue);
  font-weight: 700;
}

@media (max-width: 768px) {
  #workspace-container {
    flex-direction: column;
  }
  #iframe-pane {
    border-left: none;
    border-top: 2px solid var(--arch-blue);
    height: 55%;
  }
}