/* =============================================
   CIPHERLAB v2 — TERMINAL / CLI AESTHETIC
   ============================================= */

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

:root {
  --bg:        #0a0a0a;
  --bg2:       #0f0f0f;
  --bg3:       #141414;
  --line:      #1e1e1e;
  --line2:     #2a2a2a;
  --green:     #00ff88;
  --green-dim: #00ff8820;
  --green-mid: #00ff8866;
  --amber:     #ffb800;
  --amber-dim: #ffb80018;
  --red:       #ff4455;
  --cyan:      #00d4ff;
  --cyan-dim:  #00d4ff15;
  --white:     #f0f0f0;
  --grey:      #888;
  --grey2:     #555;
  --grey3:     #333;
  --mono:      'JetBrains Mono', monospace;
  --sans:      'Space Grotesk', sans-serif;
  --topbar-h:  52px;
  --statusbar-h: 28px;
}

html, body {
  height: 100%;
  width: 100%;
  background: var(--bg);
  color: var(--white);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  overflow: hidden;
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--grey3); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--grey2); }

/* =====================
   TOP BAR
   ===================== */
.topbar {
  height: var(--topbar-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--line2);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 0;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
}

.topbar-left {
  display: flex;
  align-items: baseline;
  gap: 8px;
  width: 180px;
  flex-shrink: 0;
}

.topbar-logo {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--green);
  letter-spacing: 0.12em;
}

.topbar-version {
  font-size: 10px;
  color: var(--grey2);
  letter-spacing: 0.05em;
}

.topbar-tabs {
  display: flex;
  align-items: stretch;
  gap: 0;
  flex: 1;
  height: 100%;
}

.tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 22px;
  background: transparent;
  border: none;
  border-right: 1px solid var(--line2);
  color: var(--grey2);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all .15s;
  position: relative;
}

.tab:first-child { border-left: 1px solid var(--line2); }

.tab:hover { color: var(--white); background: var(--bg3); }

.tab.active {
  color: var(--green);
  background: var(--bg3);
}

.tab.active::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  background: var(--green);
}

.tab-num {
  font-size: 9px;
  color: var(--grey3);
  font-weight: 400;
}

.tab.active .tab-num { color: var(--green-mid); }

.topbar-right {
  width: 120px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.status-dot {
  width: 6px; height: 6px;
  background: var(--green);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--green);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.status-text {
  font-size: 10px;
  color: var(--green);
  letter-spacing: 0.12em;
}

/* =====================
   WORKSPACE
   ===================== */
.workspace {
  display: grid;
  grid-template-columns: 380px 1fr;
  height: calc(100vh - var(--topbar-h) - var(--statusbar-h));
  margin-top: var(--topbar-h);
  width: 100%;
  overflow: hidden;
}

/* =====================
   PANE (LEFT & RIGHT)
   ===================== */
.pane {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--line2);
}

.pane-output { border-right: none; }

.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg2);
  border-bottom: 1px solid var(--line2);
  flex-shrink: 0;
}

.pane-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--grey2);
}

.pane-dots {
  display: flex;
  gap: 5px;
}

.pane-dots span {
  width: 8px; height: 8px;
  border-radius: 50%;
}

.pane-dots span:nth-child(1) { background: #ff5f57; }
.pane-dots span:nth-child(2) { background: #febc2e; }
.pane-dots span:nth-child(3) { background: #28c840; }

/* =====================
   INPUT PANE
   ===================== */
.pane-input .panel {
  display: none;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.pane-input .panel.active { display: flex; }

/* CIPHER INFO BLOCK */
.cipher-info {
  padding: 14px;
  background: var(--bg3);
  border: 1px solid var(--line2);
  border-left: 3px solid var(--green);
  border-radius: 2px;
}

.cipher-tag {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--green);
  margin-bottom: 4px;
}

.cipher-name {
  font-family: var(--sans);
  font-size: 18px;
  font-weight: 700;
  color: var(--white);
  margin-bottom: 4px;
}

.cipher-formula {
  font-size: 12px;
  color: var(--amber);
  letter-spacing: 0.04em;
}

/* MODE ROW (toggle buttons) */
.mode-row {
  display: flex;
  gap: 0;
  border: 1px solid var(--green);
  border-radius: 2px;
  overflow: hidden;
  flex-shrink: 0;
}

.mode-toggle-btn {
  flex: 1;
  padding: 10px 8px;
  background: var(--bg2);
  border: none;
  border-right: 1px solid var(--line2);
  color: var(--grey2);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  cursor: pointer;
  transition: all .15s;
}

.mode-toggle-btn:last-child { border-right: none; }

.mode-toggle-btn:hover {
  color: var(--white);
  background: var(--bg3);
}

.mode-toggle-btn.active {
  background: var(--green-dim);
  color: var(--green);
  border-bottom: 2px solid var(--green);
}

/* FIELD */
.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 10px;
  color: var(--green);
  letter-spacing: 0.05em;
}

.hint {
  color: var(--grey2);
  font-weight: 400;
}

.term-input {
  background: var(--bg3);
  border: 1px solid var(--line2);
  border-radius: 2px;
  color: var(--white);
  font-family: var(--mono);
  font-size: 13px;
  padding: 9px 12px;
  outline: none;
  resize: vertical;
  width: 100%;
  transition: border-color .15s;
}

.term-input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 2px var(--green-dim);
}

.term-input::placeholder { color: var(--grey3); }

.term-select { cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23555' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

.inline-row {
  display: flex;
  gap: 10px;
}

/* POLY KEYS */
.poly-key-entry {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.poly-key-badge {
  font-size: 9px;
  font-weight: 700;
  color: var(--amber);
  background: var(--amber-dim);
  border: 1px solid var(--amber);
  border-radius: 2px;
  padding: 2px 6px;
  letter-spacing: 0.06em;
  flex-shrink: 0;
  width: 38px;
  text-align: center;
}

.poly-key-entry input {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--line2);
  border-radius: 2px;
  color: var(--white);
  font-family: var(--mono);
  font-size: 13px;
  padding: 7px 10px;
  outline: none;
  transition: border-color .15s;
}

.poly-key-entry input:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 2px var(--amber-dim);
}

/* MATRIX */
.matrix-wrap {
  display: grid;
  gap: 4px;
}

.matrix-wrap input {
  background: var(--bg3);
  border: 1px solid var(--line2);
  border-radius: 2px;
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  padding: 8px 4px;
  outline: none;
  transition: border-color .15s;
}

.matrix-wrap input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px var(--cyan-dim);
}

/* EXECUTE BUTTON */
.exec-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: transparent;
  border: 1px solid var(--green);
  color: var(--green);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.15em;
  padding: 12px;
  border-radius: 2px;
  cursor: pointer;
  transition: all .15s;
  width: 100%;
  margin-top: 4px;
}

.exec-btn:hover {
  background: var(--green-dim);
  box-shadow: 0 0 16px var(--green-dim);
}

.exec-btn:active { transform: scale(.98); }

.exec-icon {
  font-size: 10px;
}

/* =====================
   OUTPUT PANE / TERMINAL
   ===================== */
.output-actions {
  display: flex;
  gap: 8px;
}

.action-btn {
  background: transparent;
  border: 1px solid var(--line2);
  color: var(--grey2);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  padding: 4px 10px;
  border-radius: 2px;
  cursor: pointer;
  transition: all .15s;
}

.action-btn:hover { color: var(--white); border-color: var(--grey2); }

.terminal {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.7;
  background: var(--bg);
}

/* WELCOME SCREEN */
.term-welcome {
  color: var(--grey2);
}

.welcome-art {
  color: var(--green-mid);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre;
  margin-bottom: 16px;
}

.welcome-hint {
  font-size: 12px;
  color: var(--grey2);
}

.welcome-hint kbd {
  background: var(--bg3);
  border: 1px solid var(--line2);
  color: var(--green);
  padding: 1px 6px;
  border-radius: 2px;
  font-family: var(--mono);
  font-size: 11px;
}

/* TERMINAL LOG BLOCKS */
.log-block {
  margin-bottom: 24px;
  animation: logIn .2s ease;
}

@keyframes logIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.log-cmd {
  color: var(--green);
  margin-bottom: 8px;
  font-weight: 600;
}

.log-cmd::before { content: '❯ '; color: var(--grey2); }

/* FLOW PIPELINE */
.log-flow {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0;
  margin-bottom: 14px;
  background: var(--bg2);
  border: 1px solid var(--line2);
  border-radius: 2px;
  overflow: hidden;
}

.flow-step {
  display: flex;
  flex-direction: column;
  padding: 10px 14px;
  border-right: 1px solid var(--line2);
  flex: 1;
  min-width: 80px;
}

.flow-step:last-child { border-right: none; }

.flow-step-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--grey2);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.flow-step-value {
  font-size: 12px;
  color: var(--amber);
  word-break: break-all;
}

.flow-step.step-result .flow-step-value {
  color: var(--green);
  font-weight: 600;
}

.flow-arrow-sep {
  color: var(--grey3);
  font-size: 16px;
  padding: 0 4px;
  flex-shrink: 0;
}

/* RESULT OUTPUT */
.log-result-label {
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--grey2);
  margin-bottom: 6px;
}

.log-result-value {
  font-size: 22px;
  font-weight: 600;
  color: var(--green);
  letter-spacing: 0.06em;
  word-break: break-all;
  line-height: 1.4;
  padding: 12px;
  background: var(--green-dim);
  border-left: 3px solid var(--green);
  border-radius: 0 2px 2px 0;
  margin-bottom: 14px;
}

/* KEY INFO (RSA) */
.log-keyinfo {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.log-keyinfo-item {
  background: var(--bg3);
  border: 1px solid var(--line2);
  border-radius: 2px;
  padding: 6px 12px;
  font-size: 11px;
  color: var(--grey);
}

.log-keyinfo-item b { color: var(--cyan); }

/* STEPS TABLE */
.log-steps-header {
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--grey2);
  margin-bottom: 4px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
}

.log-step {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 3px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

.log-step:last-child { border-bottom: none; }

.step-n {
  color: var(--grey3);
  font-size: 10px;
  min-width: 20px;
  flex-shrink: 0;
}

.step-calc { color: var(--grey); flex: 1; }

.step-out {
  color: var(--amber);
  font-weight: 600;
  flex-shrink: 0;
}

.log-section-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--grey2);
  text-transform: uppercase;
  padding: 8px 0 3px;
  border-top: 1px solid var(--line2);
  margin-top: 4px;
}

/* ERROR */
.log-error {
  color: var(--red);
  padding: 10px 12px;
  border-left: 3px solid var(--red);
  background: #ff445510;
  font-size: 12px;
}

.log-error::before { content: '✖ '; }

/* CURSOR BLINK */
.cursor {
  display: inline-block;
  width: 8px; height: 14px;
  background: var(--green);
  margin-left: 2px;
  vertical-align: middle;
  animation: blink .8s step-end infinite;
}

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

/* =====================
   STATUS BAR
   ===================== */
.statusbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--statusbar-h);
  background: var(--green);
  color: var(--bg);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 10px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--mono);
  letter-spacing: 0.05em;
  z-index: 100;
}

.sb-sep { color: #00884433; }

/* =====================
   RESPONSIVE
   ===================== */
@media (max-width: 900px) {
  .workspace { grid-template-columns: 340px 1fr; }
}

@media (max-width: 700px) {
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    height: auto;
    overflow: visible;
  }
  html, body { overflow: auto; }
  .pane-input { max-height: 60vh; }
  .tab { padding: 0 10px; font-size: 11px; }
  .tab-num { display: none; }
}
