:root,
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1216;
  --surface: #171b21;
  --text: #e3e7ec;
  --muted: #9aa4b1;
  --border: #2f3640;
  --accent: #4c8dff;
  --accent-text: #0b0d10;
  --ok-bg: #12261a;
  --ok-border: #2f6b43;
  --warn-bg: #2b2310;
  --warn-border: #7a6224;
  --err-bg: #2d1414;
  --err-border: #7d3434;
  --mono: "Cascadia Code", "Cascadia Mono", "Fira Code", ui-monospace, "SFMono-Regular", Consolas, Menlo, monospace;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1c2128;
  --muted: #5d6673;
  --border: #d5dae1;
  --accent: #1f6feb;
  --accent-text: #ffffff;
  --ok-bg: #e9f6ee;
  --ok-border: #8fd1a6;
  --warn-bg: #fff6e0;
  --warn-border: #e8c260;
  --err-bg: #fdecec;
  --err-border: #ef9a9a;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  transition: background-color 0.25s ease, color 0.25s ease;
  overflow-x: hidden;
}

.panel, textarea, button {
  transition: background-color 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}

.container {
  max-inline-size: 1340px;
  margin-inline: auto;
  padding: 24px 24px 40px;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
  position: relative;
}

.header h1 {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 1.02rem;
  font-weight: 500;
}

/* Pull Cord Lamp Switch Toggle (Coffee Style) */
.cord-fixture {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
  touch-action: none;
  margin-top: -24px;
  margin-right: -8px;
  padding: 0 8px;
  z-index: 25;
}
.cord-fixture:active { cursor: grabbing; }

.cord-anchor-plate {
  width: 20px;
  height: 9px;
  border-radius: 0 0 3px 3px;
  background: linear-gradient(180deg, #43281c 0%, #2b170c 100%);
  border: 1px solid rgba(221, 184, 146, 0.35);
  border-top: none;
  box-shadow: 0 2px 6px rgba(20, 10, 5, 0.6);
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cord-indicator-bulb {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  transition: all 0.3s ease;
}
.bulb-lit {
  background-color: #ddb892;
  box-shadow: 0 0 8px #b08968, 0 0 16px #ddb892;
}
.bulb-off {
  background-color: #6f4e37;
  box-shadow: 0 0 5px #3f2817;
}

.cord-interactive-area {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 12px;
  outline: none;
}

.rope-stem {
  width: 2.5px;
  height: 32px;
  background: linear-gradient(180deg, #7f5539 0%, #b08968 50%, #e6ccb2 100%);
  transform-origin: top center;
  box-shadow: 0 0 3px rgba(35, 18, 10, 0.6);
  position: relative;
  overflow: hidden;
}
.rope-stem::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.45;
  background: repeating-linear-gradient(45deg, rgba(43, 23, 12, 0.5) 0, rgba(43, 23, 12, 0.5) 1px, transparent 1px, transparent 3px);
}

.cord-handle {
  position: relative;
  margin-top: -1px;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: filter 0.15s ease;
}
.cord-handle:hover { filter: brightness(1.15); }

.cord-bead-top {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #6f4e37;
  border: 1px solid #43281c;
  box-shadow: 0 1px 3px rgba(25, 12, 5, 0.4);
}
.cord-bead-main {
  width: 12px;
  height: 18px;
  border-radius: 8px;
  background: linear-gradient(135deg, #3f2314 0%, #6f4e37 38%, #9c6644 68%, #3f2314 100%);
  border: 1px solid #2b170c;
  box-shadow: 0 4px 10px rgba(20, 10, 5, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: -1px;
}
.cord-bead-inner {
  width: 4px;
  height: 9px;
  border-radius: 4px;
  background: rgba(246, 235, 224, 0.45);
}
.cord-bead-cap {
  width: 6px;
  height: 4px;
  border-radius: 0 0 3px 3px;
  background: #2b170c;
  border: 1px solid #1a0e07;
  margin-top: -1px;
}

.pull-cue {
  position: absolute;
  bottom: -8px;
  width: 16px;
  height: 2px;
  border-radius: 2px;
  background: transparent;
  transition: all 0.2s ease;
  pointer-events: none;
}

.cord-tooltip {
  pointer-events: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 10px;
  white-space: nowrap;
  padding: 5px 9px;
  border-radius: 5px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  background: #231610;
  color: #ede0d4;
  border: 1px solid rgba(221, 184, 146, 0.28);
  box-shadow: 0 6px 18px rgba(10, 5, 2, 0.7);
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
}
.cord-fixture:hover .cord-tooltip,
.cord-fixture:focus-visible .cord-tooltip {
  opacity: 1;
  transform: translateY(0);
}

@keyframes cordReleaseSnap {
  0% { height: var(--release-height, 58px); }
  30% { height: 25px; }
  55% { height: 36px; }
  75% { height: 30px; }
  90% { height: 33px; }
  100% { height: 32px; }
}
@keyframes handleReleaseSnap {
  0% { transform: translateY(var(--release-y, 26px)); }
  30% { transform: translateY(-7px); }
  55% { transform: translateY(4px); }
  75% { transform: translateY(-2px); }
  90% { transform: translateY(1px); }
  100% { transform: translateY(0); }
}

.cord-snapping .rope-stem {
  animation: cordReleaseSnap 0.55s cubic-bezier(0.25, 1, 0.5, 1) forwards !important;
}
.cord-snapping .cord-handle {
  animation: handleReleaseSnap 0.55s cubic-bezier(0.25, 1, 0.5, 1) forwards !important;
}

.panel {
  min-inline-size: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 15px 17px;
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

label,
.panel-heading {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
}

textarea {
  display: block;
  width: 100%;
  min-block-size: 168px;
  resize: vertical;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.6;
  letter-spacing: 0.012em;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

#output { min-block-size: 155px; }

textarea:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 11px;
}

.mode-group {
  display: inline-flex;
  flex-wrap: wrap;
  max-inline-size: 100%;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}

.mode-btn {
  font-size: 13px;
  font-weight: 600;
  padding: 5px 10px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
}

.mode-btn:hover {
  border-color: transparent;
  color: var(--text);
}

.mode-btn.active {
  background: var(--surface);
  border-color: var(--border);
  color: var(--accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}

button {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  letter-spacing: 0.01em;
}

button:hover { border-color: var(--muted); }

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

button.primary:hover { filter: brightness(1.08); }

.hint {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
}

.status {
  border: 1px solid var(--ok-border);
  background: var(--ok-bg);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 0.98rem;
}

.status.warn { border-color: var(--warn-border); background: var(--warn-bg); }
.status.error { border-color: var(--err-border); background: var(--err-bg); }

.status strong {
  display: block;
  font-size: 1.05rem;
  font-weight: 700;
}

.status .steps {
  font-family: var(--mono);
  font-size: 0.92rem;
  font-weight: 600;
  margin-top: 4px;
  letter-spacing: 0.015em;
  overflow-wrap: anywhere;
}

.status ul {
  margin: 8px 0 0;
  padding-left: 22px;
  font-size: 0.94rem;
  font-weight: 500;
  line-height: 1.55;
}

.status li { margin: 3px 0; }

.footer {
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.6;
  text-align: center;
  max-width: 820px;
  margin: 28px auto 0;
}

/* ------------------------------------------------------------------ */
/* Two-column Option B workspace + flow pipes                         */
/* ------------------------------------------------------------------ */
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.22fr) minmax(0, 0.98fr);
  column-gap: 28px;
  row-gap: 16px;
  align-items: start;
}

.lane-left,
.lane-right {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-inline-size: 0;
}

.lane-right .status { margin-bottom: 0; }

.flow-pipe-v {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-block: -7px;
  color: var(--accent);
}

.flow-pipe-v svg {
  display: block;
  width: 28px;
  height: 28px;
  padding: 4px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid rgba(76, 141, 255, 0.45);
  box-shadow: 0 2px 10px rgba(76, 141, 255, 0.14);
}

/* ------------------------------------------------------------------ */
/* Positioning sub-tagline                                            */
/* ------------------------------------------------------------------ */
.subtagline {
  margin: 5px 0 0;
  max-inline-size: 760px;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

/* ------------------------------------------------------------------ */
/* Compact two-column Samples card (top-right rail)                   */
/* ------------------------------------------------------------------ */
.panel-samples { padding: 13px 15px; }

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

.sample-btn {
  min-inline-size: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 7px 11px;
  border-radius: 9px;
  border: 1px dashed var(--border);
  background: var(--bg);
  text-align: left;
  line-height: 1.25;
}

.sample-btn:last-child:nth-child(odd) {
  grid-column: span 2;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
}

.sample-btn:hover { border-color: var(--accent); }

.sample-btn.active {
  border-style: solid;
  border-color: var(--accent);
  background: rgba(76, 141, 255, 0.12);
  box-shadow: 0 0 0 1px var(--accent) inset;
}

.sample-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.sample-chain {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  overflow-wrap: anywhere;
}

/* Layer badge in status title */
.layer-badge {
  display: inline-block;
  margin-left: 10px;
  padding: 1px 9px;
  border-radius: 999px;
  border: 1px solid var(--ok-border);
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 700;
  vertical-align: 2px;
}

/* ------------------------------------------------------------------ */
/* IOC panel + pipe connector & pipe flag                             */
/* ------------------------------------------------------------------ */
.panel-ioc {
  position: relative;
}

.ioc-pipe-bridge {
  position: absolute;
  inset-inline-start: -29px;
  inset-block-start: 18px;
  inline-size: 29px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  pointer-events: none;
}

.ioc-pipe-bridge svg {
  display: block;
  width: 26px;
  height: 24px;
  padding: 3px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid rgba(76, 141, 255, 0.5);
  box-shadow: 0 2px 10px rgba(76, 141, 255, 0.18);
}

.ioc-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.ioc-title-group {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
}

.ioc-title {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ioc-pipe-flag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid rgba(76, 141, 255, 0.42);
  background: rgba(76, 141, 255, 0.11);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.ioc-pipe-flag svg {
  display: block;
  flex: 0 0 auto;
}

.ioc-count {
  display: inline-block;
  min-width: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 0.78rem;
  text-align: center;
}

.ioc-actions {
  display: flex;
  flex-wrap: wrap;
  flex-wrap: balance;
  gap: 8px;
}

.ioc-actions button { padding: 7px 14px; font-size: 13px; }

.ioc-hint { margin: 8px 0 10px; font-size: 0.85rem; }

.ioc-list {
  list-style: none;
  margin: 0 0 6px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 9px;
  overflow: hidden;
  max-block-size: 480px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.ioc-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 10px;
  background: var(--bg);
  border-top: 1px solid var(--border);
}

.ioc-item:first-child { border-top: none; }

.ioc-type {
  flex: 0 0 60px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  padding: 2px 0;
  border-radius: 5px;
  border: 1px solid var(--border);
  color: var(--muted);
}

.ioc-type-url { color: #f0883e; border-color: rgba(240, 136, 62, 0.45); }
.ioc-type-domain { color: #a371f7; border-color: rgba(163, 113, 247, 0.45); }
.ioc-type-ipv4, .ioc-type-ipv6 { color: #3fb950; border-color: rgba(63, 185, 80, 0.45); }
.ioc-type-email { color: #58a6ff; border-color: rgba(88, 166, 255, 0.45); }
.ioc-type-md5, .ioc-type-sha1, .ioc-type-sha256 { color: #d29922; border-color: rgba(210, 153, 34, 0.45); }
.ioc-type-cve { color: #f85149; border-color: rgba(248, 81, 73, 0.45); }

.ioc-value {
  flex: 1 1 auto;
  min-width: 0;
  font-family: var(--mono);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.ioc-tag {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: var(--text);
  white-space: nowrap;
}

.ioc-copy {
  flex: 0 0 auto;
  padding: 3px 10px;
  font-size: 12px;
}

@media (max-width: 960px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }
  .ioc-pipe-bridge { display: none; }
}

@media (max-width: 640px) {
  .container { padding: 18px 14px 36px; }
  .samples-grid { grid-template-columns: minmax(0, 1fr); }
  .sample-btn:last-child:nth-child(odd) {
    grid-column: auto;
    flex-direction: column;
    gap: 2px;
  }
  .ioc-item { flex-wrap: wrap; }
  .ioc-value { flex-basis: 100%; order: 3; }
}
