/* ========================================
   Theme
======================================== */
:root {
  --bg: #0b0c10;
  --panel: #12141a;
  --ink: #e8e8ea;
  --ink-dim: #b7b7be;
  --accent: #5cc3ff;
  --accent-2: #8affc1;
  --warn: #ffbe5c;
  --bad: #ff6b6b;
  --ok: #8affc1;
  --muted: #2a2e39;
}

/* ========================================
   Base / Reset
======================================== */
* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font: 14px/1.4 system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--ink);
  background: linear-gradient(180deg, var(--bg), #0f1118 45%, #0b0c10);
}

/* ========================================
   Layout
======================================== */
.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.footer-bar {
  max-width: 1200px;
  margin: 8px auto 18px;
  padding: 0 20px;
  display: flex;
  justify-content: flex-end;
}

header {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.grid {
  display: block;
}

.grid-below {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 16px;
  align-items: start;
}

@media (max-width:980px) {
  .grid-below {
    grid-template-columns: 1fr;
  }
}

.stack {
  display: grid;
  row-gap: 1rem;
}

.card {
  background: var(--panel);
  border: 1px solid #181b24;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
  overflow: hidden;
}

.section {
  padding: 14px;
}

/* ========================================
   Typography
======================================== */
h1 {
  font-size: 20px;
  margin: 0;
  letter-spacing: .2px;
}

.section h2 {
  margin: 0 0 10px;
  font-size: 15px;
  color: var(--ink-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.hint {
  color: var(--ink-dim);
  font-size: 12px;
}

.kpi {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  color: var(--ink-dim);
}

.kpi strong {
  color: var(--ink);
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

/* ========================================
   Form Controls
======================================== */
textarea {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  color: var(--ink);
  background: #0f1219;
  border: 1px solid #1b2130;
  border-radius: 12px;
  padding: 12px;
  caret-color: var(--accent);
}

.controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.controls--compact {
  display: flex;
  flex-direction: column;
  gap: 4px; /* was 10px */
}

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

.row-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

label {
  font-size: 13px;
  color: var(--ink-dim);
}

input[type="number"],
input[type="text"],
select {
  width: 100%;
  background: #0f1219;
  color: var(--ink);
  border: 1px solid #1b2130;
  border-radius: 10px;
  padding: 8px;
}

input[type="checkbox"] {
  accent-color: var(--accent);
}

/* Counter one-liner specifics */
#counterPlacement {
  width: auto;
  min-width: 0;
  display: inline-block;
}

#counterPlacement + .muted {
  white-space: nowrap;
}

/* Continuation marker dropdown: keep it narrow */
#continuationMarker {
  width: auto;
  min-width: 0;
  max-width: 60px;
  display: inline-block;
  text-align: center;
  padding-inline: 4px;
}

.controls--compact .nowrap {
  white-space: nowrap;
}

.controls--compact input[type="number"] {
  max-width: 110px;
}

.controls--compact select {
  max-width: 160px;
}

/* Keep row height stable so nothing jumps when we hide parts */
:root {
  --control-h: 28px; /* was 40px */
}

.controls--compact .row {
  min-height: var(--control-h);
  align-items: center;
}

/* ========================================
   Action Bars & Buttons
======================================== */
.section-actions {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  margin: 0 0 8px 0;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.section-actions--right {
  justify-content: flex-end;
}

.btn {
  appearance: none;
  background: #10141d;
  border: 1px solid #2a3b57;
  color: var(--ink);
  padding: 5px 10px;
  border-radius: 10px;
  font-weight: 400;
  line-height: 1.2;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease, transform .08s ease;
}

.btn:hover {
  background: #182235;
  border-color: #3c557d;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .25);
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(92, 195, 255, .25), 0 2px 10px rgba(0, 0, 0, .25);
  border-color: #4b84ba;
}

.btn:active {
  transform: translateY(1px);
}

/* Toggle “activated” (for Auto-split / Advanced) */
.btn[aria-pressed="true"] {
  background: #24324b;
  border-color: #4a77b2;
}

.btn[aria-pressed="true"]:hover {
  background: #2b3b59;
  border-color: #6aa0e0;
}

/* Disabled */
.btn:disabled {
  background: #0a0f1a;
  border-color: #0f182a;
  color: #6e7a8a;
  opacity: .55;
  box-shadow: none;
  transform: none;
  cursor: not-allowed;
}

.btn:disabled:hover,
.btn:disabled:active {
  background: #0a0f1a;
  border-color: #0f182a;
  box-shadow: none;
  transform: none;
}

/* Reduced motion */
@media (prefers-reduced-motion:reduce) {
  .btn {
    transition: none;
  }
}

/* ========================================
   Output / Parts
======================================== */
.out {
  padding: 0 16px 16px;
}

.chunks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.chunk {
  background: #0f1219;
  border: 1px solid #1b2130;
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chunk header {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin: 0;
}

.bar {
  height: 6px;
  background: var(--muted);
  border-radius: 999px;
  overflow: hidden;
}

.bar > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  width: 0%;
}

.footer {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.pill {
  font-size: 11px;
  color: var(--ink-dim);
  border: 1px dashed #2f3547;
  padding: 4px 8px;
  border-radius: 999px;
}

.content {
  white-space: pre-wrap;
  overflow-wrap: anywhere;  /* allow breaking long words/URLs */
  word-break: break-word;   /* extra safety for older browsers */
}

/* ========================================
   Semantic States
======================================== */
.bad {
  color: var(--bad);
}

.warn {
  color: var(--warn);
}

.ok {
  color: var(--ok);
}

/* ========================================
   Utilities
======================================== */
.sticky {
  position: sticky;
  top: 12px;
}

@media (min-width:981px) {
  .card.section.sticky {
    max-height: calc(100vh - 24px);
    overflow: auto;
  }
}

.muted {
  opacity: .8;
}

/* Advanced toggles */
.adv {
  display: none;
}

body.advanced .adv {
  display: inline-flex;
}

/* Visually-hidden utility if needed elsewhere */
.sr-only {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ========================================
   Per-part max override controls
======================================== */

.part-max {
  display: none;                 /* shown when per-part override is enabled */
  align-items: center;
  gap: 4px;
  margin-left: 0.5rem;
}

body.per-part-on .part-max {
  display: inline-flex;
}

/* Make the input and +/- buttons roughly the same height as the main button */
.part-max-input {
  flex: 0 0 auto;
  width: 7.5ch;      /* slightly wider to account for spinner + 3 digits */
  min-width: 7.5ch;
  max-width: 9ch;
  text-align: center;
  padding: 0 2px;
  height: 26px;
  border-radius: 4px;
  font-size: 0.8rem;
}

.btn-icon {
  padding: 0 6px;
  height: 26px;
  line-height: 1;
  font-size: 0.8rem;
}
