/* Cipher Lab — strictly Chalk Violet, Deep Aubergine Ink, Royal Purple. */
:root {
  color-scheme: light;
  --canvas: #F4F2F7;
  --ink: #1A112B;
  --accent: #7B2CBF;
  --hair: var(--ink);
  --mono: 'JetBrains Mono', 'Fira Code', 'SFMono-Regular', Consolas, monospace;
}

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

html, body { height: 100%; }
html { scrollbar-color: var(--ink) var(--canvas); }

body {
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; color: inherit; }

::selection { background: var(--ink); color: var(--canvas); }

.lab {
  display: grid;
  grid-template-columns: 75% 25%;
  height: 100vh;
}

/* ---------- workspace ---------- */
.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--hair);
}

.label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 48px;
  padding: 0 16px;
  border-bottom: 1px solid var(--hair);
}

.bar-left, .bar-right { display: flex; align-items: center; gap: 12px; min-width: 0; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border: 1px solid var(--ink);
  border-radius: 13px;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.param { display: inline-flex; align-items: center; gap: 8px; }
.param[hidden] { display: none; }
.param-label { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }
.param-input {
  width: 120px;
  height: 26px;
  padding: 0 8px;
  background: var(--canvas);
  border: 1px solid var(--hair);
  font-size: 12px;
}

.seg {
  display: inline-flex;
  height: 26px;
  border: 1px solid var(--ink);
  border-radius: 13px;
  overflow: hidden;
}
.seg-btn {
  padding: 0 12px;
  background: transparent;
  border: 0;
  font-size: 12px;
  letter-spacing: 0.04em;
  cursor: pointer;
}
.seg-btn + .seg-btn { border-left: 1px solid var(--ink); }
.seg-btn.is-active { background: var(--accent); color: var(--canvas); }

.btn {
  height: 26px;
  padding: 0 10px;
  background: transparent;
  border: 1px solid var(--ink);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--ink); color: var(--canvas); }
.btn.is-copied, .btn.is-copied:hover { background: var(--accent); color: var(--canvas); border-color: var(--ink); }

/* ---------- editor ---------- */
.editor {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 0;
  border-bottom: 1px solid var(--hair);
}

.pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.pane + .pane { border-left: 1px solid var(--hair); }

.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 40px;
  padding: 0 16px;
  border-bottom: 1px solid var(--hair);
}
.pane-tools { display: flex; align-items: center; gap: 12px; }
.count { font-variant-numeric: tabular-nums; }

.area {
  flex: 1;
  width: 100%;
  min-height: 0;
  padding: 16px;
  background: var(--canvas);
  border: 0;
  resize: none;
  font-size: 13px;
  line-height: 1.6;
  word-break: break-all;
  white-space: pre-wrap;
}
.area[readonly] { cursor: text; }
.area.is-error { font-style: italic; }

/* ---------- info ---------- */
.info {
  margin: 16px;
  padding: 14px 16px;
  border: 1px solid var(--hair);
}
.info-text {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.6;
  max-width: 90ch;
}

/* ---------- sidebar ---------- */
.sidebar { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.side-head {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--hair);
}
.search {
  width: 100%;
  height: 30px;
  padding: 0 10px;
  background: var(--canvas);
  border: 1px solid var(--hair);
  font-size: 12px;
}
.search::placeholder { color: var(--ink); opacity: 1; }

.list { flex: 1; overflow-y: auto; padding-bottom: 16px; }

.cat-title {
  display: flex;
  justify-content: space-between;
  padding: 14px 16px 6px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.item {
  display: block;
  width: 100%;
  padding: 5px 16px;
  background: transparent;
  border: 0;
  text-align: left;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.item:hover { background: var(--ink); color: var(--canvas); }
.item.is-active, .item.is-active:hover { background: var(--accent); color: var(--canvas); }

.empty { padding: 16px; font-size: 12px; }

/* ---------- focus ---------- */
:focus { outline: none; }
:focus-visible, .search:focus, .param-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.area:focus { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ---------- narrow screens ---------- */
@media (max-width: 860px) {
  .lab { grid-template-columns: 1fr; height: auto; }
  .workspace { border-right: 0; border-bottom: 1px solid var(--hair); }
  .editor { grid-template-columns: 1fr; }
  .pane { min-height: 220px; }
  .pane + .pane { border-left: 0; border-top: 1px solid var(--hair); }
  .bar { height: auto; padding: 10px 16px; flex-wrap: wrap; }
  .list { max-height: 60vh; }
}
