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

:root {
  --bg-deep:    #0d1117;
  --bg-panel:   #161b22;
  --bg-header:  #1c2230;
  --bg-hover:   #1f2937;
  --border:     #30363d;
  --text:       #c9d1d9;
  --text-dim:   #6e7681;
  --accent:     #e63946;
  --accent-dk:  #9b1922;
  --blue:       #58a6ff;
  --mono: 'Menlo', 'Monaco', 'Courier New', monospace;
  --ui:   -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body {
  font-family: var(--ui);
  background: var(--bg-deep);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── MENU ─────────────────────────────── */
#menu {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#menu-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: .4px;
  margin-right: 8px;
  white-space: nowrap;
}

.sep { width: 1px; height: 20px; background: var(--border); margin: 0 5px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-header);
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  font-family: var(--ui);
  white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--bg-hover); border-color: #555; }
.btn-primary { background: var(--accent); border-color: var(--accent-dk); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--accent-dk); }

#status-msg {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 400px;
}

/* ── LAYOUT ────────────────────────────── */
#layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.v-resizer {
  width: 4px;
  background: var(--border);
  cursor: col-resize;
  flex-shrink: 0;
  transition: background .12s;
  z-index: 10;
}
.v-resizer:hover, .v-resizer.active { background: var(--accent); }

/* ── PANEL CHROME ──────────────────────── */
.panel-header {
  padding: 5px 12px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-dim);
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.expand-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  padding: 0;
  line-height: 1;
  opacity: .4;
  transition: opacity .12s, color .12s;
  flex-shrink: 0;
}
.expand-btn:hover { opacity: 1; color: var(--text); }

/* ── EXPAND / FOCUS MODE ───────────────── */
#layout.layout-has-focus .panel:not(.panel-maximized),
#layout.layout-has-focus .v-resizer { display: none; }
.panel-maximized { flex: 1 !important; }

.sec-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 10px;
  font-size: 11px;
  color: var(--text-dim);
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 8px;
  min-height: 27px;
}

.sec-label { font-weight: 600; white-space: nowrap; }

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 16px;
  padding: 0 5px;
  background: var(--accent-dk);
  color: #fff;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 700;
}

/* ── FILE LISTS ────────────────────────── */
.list-section {
  display: flex;
  flex-direction: column;
  flex: 0 0 160px;
  border-bottom: 2px solid var(--border);
  overflow: hidden;
}

.file-list {
  overflow-y: auto;
  flex: 1;
}

.file-item {
  display: flex;
  align-items: center;
  padding: 5px 10px;
  font-size: 11.5px;
  font-family: var(--mono);
  cursor: pointer;
  border-bottom: 1px solid #0f141a;
  gap: 6px;
  min-height: 28px;
  user-select: none;
}
.file-item:hover { background: var(--bg-hover); }
.file-item.active { background: #1d4ed8; color: #fff; }

.item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-tag {
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 3px;
  background: #1c2230;
  color: var(--text-dim);
  white-space: nowrap;
  flex-shrink: 0;
}
.file-item.active .item-tag { background: #1e40af; color: rgba(255,255,255,.75); }

.rm-btn {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: none;
  color: transparent;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .1s, color .1s;
}
.file-item:hover .rm-btn { color: var(--text-dim); }
.rm-btn:hover { background: rgba(255,255,255,.1); color: var(--accent) !important; }

/* ── EDITORS / VIEWERS ─────────────────── */
.editor-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

textarea, .code-view {
  flex: 1;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.65;
  padding: 12px 14px;
  border: none;
  outline: none;
  overflow: auto;
  white-space: pre;
  background: var(--bg-deep);
  color: var(--text);
  resize: none;
  tab-size: 2;
}

.code-view code.hljs { background: transparent; padding: 0; }
.code-view.empty code { display: none; }
.code-view.empty::before {
  content: 'Select a generated file to view its content.';
  color: var(--text-dim);
  font-style: italic;
  font-family: var(--ui);
}

/* ── PANELS ────────────────────────────── */
#panel-storm   { flex: 0 0 240px; }
#panel-gherkin { flex: 0 0 240px; }
#panel-left    { flex: 0 0 300px; }
#panel-middle  { flex: 1; }
#panel-right   { flex: 1; }

/* ── TEMPLATE NAME INPUT ───────────────── */
#tpl-name-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 2px 6px;
  outline: none;
  transition: border-color .12s, background .12s;
}
#tpl-name-input:hover:not(:focus):not(:disabled) { border-color: var(--border); }
#tpl-name-input:focus { border-color: var(--accent); background: var(--bg-deep); }
#tpl-name-input:disabled { opacity: .4; cursor: default; }

.vars-hint {
  font-size: 10px;
  color: #3a4050;
  font-family: var(--mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}

/* ── FILTER SELECT ─────────────────────── */
select {
  background: var(--bg-deep);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-family: var(--ui);
  outline: none;
  cursor: pointer;
}
select:hover { border-color: #555; }

/* ── STATUS BAR ────────────────────────── */
#status-bar {
  flex-shrink: 0;
  padding: 3px 14px;
  font-size: 11px;
  color: var(--text-dim);
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  font-family: var(--mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── TEMPLATE HIGHLIGHT OVERLAY ───────── */
.editor-wrapper {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.tpl-highlight {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.65;
  white-space: pre;
  tab-size: 2;
  overflow: auto;
  pointer-events: none;
  background: var(--bg-deep);
}
.tpl-highlight code.hljs { background: transparent; padding: 0; }

#tpl-editor {
  position: absolute;
  inset: 0;
  background: transparent;
  color: transparent;
  caret-color: var(--text);
  z-index: 1;
  flex: unset;
}
#tpl-editor::placeholder { color: var(--text-dim); opacity: 0.55; font-style: italic; }


/* ── SCROLLBARS ────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #30363d; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #444d56; }

/* ── EVENT STORMING PANEL ──────────────── */
.storm-editor {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 0 0 40%;
}

.h-resizer {
  height: 4px;
  background: var(--border);
  cursor: row-resize;
  flex-shrink: 0;
  transition: background .12s;
  z-index: 10;
}
.h-resizer:hover, .h-resizer.active { background: var(--accent); }

.storm-board {
  flex: 1;
  overflow: auto;
  padding: 14px;
  background: var(--bg-deep);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.storm-empty {
  color: var(--text-dim);
  font-size: 11.5px;
  font-family: var(--mono);
  padding: 12px 4px;
  line-height: 2.2;
}

.storm-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.storm-group-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--text-dim);
  border-left: 2px solid var(--border);
  padding-left: 7px;
}

.storm-stickies {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.sticky {
  width: 88px;
  min-height: 68px;
  padding: 7px 8px 6px;
  border-radius: 2px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  cursor: default;
  box-shadow: 2px 2px 5px rgba(0,0,0,.45);
  transition: transform .1s, box-shadow .1s;
}
.sticky:hover { transform: translateY(-2px); box-shadow: 3px 5px 10px rgba(0,0,0,.55); }

.sticky-type {
  font-size: 8px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  opacity: .6;
  font-family: var(--ui);
}

.sticky-label {
  font-size: 11px;
  font-weight: 600;
  line-height: 1.3;
  word-break: break-word;
  font-family: var(--ui);
}

.sticky-event     { background: #f97316; color: #1c0800; }
.sticky-command   { background: #3b82f6; color: #fff; }
.sticky-actor     { background: #fbbf24; color: #1c0800; }
.sticky-policy    { background: #a855f7; color: #fff; }
.sticky-aggregate { background: #c4b5fd; color: #1c0800; }
.sticky-system    { background: #f472b6; color: #1c0800; }
.sticky-readmodel { background: #4ade80; color: #052e16; }
.sticky-hotspot   { background: #ef4444; color: #fff; }
.sticky-note      { background: #fef08a; color: #1c0800; border: 1px dashed #92400e; }

/* ── GHERKIN PANEL ─────────────────────── */
.gherkin-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.gherkin-scenario {
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-panel);
}

.scenario-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
}

.scenario-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-dim);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: .6px;
}

.scenario-title-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  outline: none;
}
.scenario-title-input::placeholder { color: var(--text-dim); opacity: .5; font-style: italic; }

.gherkin-steps {
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.gherkin-step {
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.gherkin-kw {
  flex-shrink: 0;
  width: 40px;
  text-align: right;
  padding: 2px 5px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  font-family: var(--ui);
  line-height: 1.6;
  color: #000;
}
.gherkin-kw.given { background: #eab308; }
.gherkin-kw.when  { background: #60a5fa; }
.gherkin-kw.then  { background: #f97316; }
.gherkin-kw.and   { background: #6b7280; color: #fff; }

.gherkin-step-text {
  flex: 1;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text);
  outline: none;
  min-height: 18px;
  word-break: break-word;
  white-space: pre-wrap;
  line-height: 1.6;
}

.add-step-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 5px 8px 7px;
  border-top: 1px solid var(--border);
  background: var(--bg-deep);
}

.btn-step { padding: 2px 7px; font-size: 10px; }
.btn-step-given { border-color: #92400e; color: #fbbf24; }
.btn-step-when  { border-color: #1e40af; color: #93c5fd; }
.btn-step-then  { border-color: #9a3412; color: #fb923c; }
.btn-step-and   { border-color: #374151; color: #9ca3af; }
