:root {
  --bg-top: #2f3948;
  --bg-bottom: #2f3948;
  --panel: #344152;
  --ink: #e6ebf2;
  --muted: #b4c0d1;
  --accent: #3ea894;
  --accent-strong: #2f8a79;
  --line: #4a5a72;
  --shadow: 0 14px 28px rgba(7, 12, 20, 0.28);
  --input-bg: #2f3b4c;
  --button-bg: #3a4659;
  --button-hover: #455268;
  --tip-border: #7f91aa;
  --tip-ink: #dce4f1;
  --tip-bg: #16202d;
}

body[data-theme="light"] {
  --bg-top: #eef3f9;
  --bg-bottom: #eef3f9;
  --panel: #ffffff;
  --ink: #1a1f2b;
  --muted: #5a6579;
  --accent: #116d63;
  --accent-strong: #0d5a51;
  --line: #d7dde8;
  --shadow: 0 14px 28px rgba(17, 36, 64, 0.08);
  --input-bg: #ffffff;
  --button-bg: #f3f6fb;
  --button-hover: #e8eef9;
  --tip-border: #b6c0cf;
  --tip-ink: #4f5f76;
  --tip-bg: #1f2736;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  background: linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

.shell {
  max-width: 1320px;
  margin: 0 auto;
  padding: 28px;
}

.hero {
  margin-bottom: 18px;
}

.theme-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.hero h1 {
  margin: 0;
  font-size: 2.25rem;
  letter-spacing: 0.02em;
}

.theme-toggle-btn {
  min-width: 110px;
}

.hero p {
  margin: 8px 0 0;
  color: var(--muted);
  max-width: 780px;
}

.runtime-meta {
  margin-top: 6px;
  font-size: 0.86rem;
}

.workspace {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(640px, 1.25fr) minmax(420px, 1fr);
  align-items: start;
}

.footer-note {
  margin-top: 14px;
  text-align: center;
  font-size: 0.9rem;
}

.footer-note a {
  color: var(--muted);
  text-decoration: none;
}

.footer-note a:hover {
  color: var(--accent);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 16px;
}

.input-block + .input-block {
  margin-top: 12px;
}

label {
  display: block;
  font-weight: 700;
  margin-bottom: 6px;
}

textarea,
input[type="text"],
pre {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 11px 12px;
  font-family: "JetBrains Mono", "IBM Plex Mono", monospace;
  font-size: 0.92rem;
  background: var(--input-bg);
  color: var(--ink);
}

textarea {
  min-height: 182px;
  resize: vertical;
}

input[type="checkbox"],
input[type="radio"] {
  width: auto;
  margin-right: 6px;
  accent-color: var(--accent);
}

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

fieldset {
  margin: 0;
  padding: 10px 10px 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

legend {
  padding: 0 6px;
  font-weight: 700;
  color: var(--ink);
}

fieldset label {
  font-weight: 500;
  margin-bottom: 4px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.show-ws {
  margin: 0;
  font-weight: 500;
  color: var(--muted);
}

pre {
  min-height: 360px;
  margin: 0;
  white-space: pre-wrap;
  overflow: auto;
  background: var(--input-bg);
}

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

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--button-bg);
  border-radius: 8px;
  padding: 9px 12px;
  min-height: 40px;
  line-height: 1.2;
  cursor: pointer;
  font-weight: 650;
}

button:hover {
  background: var(--button-hover);
}

.btn-primary {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-strong);
}

.share-group {
  margin-top: 12px;
}

.status {
  margin: 10px 0 0;
  min-height: 1.2em;
  font-size: 0.92rem;
  color: var(--muted);
}

.status:empty {
  display: none;
}

.status.error {
  color: #9f2730;
}

.help-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-left: 6px;
  border: 1px solid var(--tip-border);
  border-radius: 999px;
  color: var(--tip-ink);
  font-size: 0.7rem;
  font-weight: 800;
  cursor: help;
  position: relative;
  vertical-align: middle;
}

.help-tip::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  min-width: 220px;
  max-width: 300px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--tip-bg);
  color: #fff;
  font-size: 0.78rem;
  line-height: 1.3;
  font-weight: 500;
  white-space: normal;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.2);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 120ms ease;
  z-index: 10;
}

.help-tip:hover::after {
  opacity: 1;
  visibility: visible;
}

.ws_space,
.ws_tab {
  display: inline-block;
  position: relative;
  padding: 0 1px;
}

.ws_newline {
  display: inline;
  position: relative;
}

.ws_space.ws_vis::after {
  content: "\2022";
  color: #8c96a6;
  position: absolute;
  left: 0;
  top: 0;
}

.ws_tab.ws_vis::after {
  content: "\21E5";
  color: #8c96a6;
  position: absolute;
  left: 0;
  top: 0;
}

.ws_newline.ws_vis::after {
  content: "\21B5";
  color: #8c96a6;
  position: absolute;
  left: 0;
  top: 0;
}

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

  .actions {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 760px) {
  .shell {
    padding: 16px;
  }

  .controls,
  .actions {
    grid-template-columns: 1fr;
  }

  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .theme-row {
    align-items: flex-start;
    flex-direction: column;
  }
}
