:root {
  --bg: #eef2f7;
  --surface: #ffffff;
  --surface-soft: #f8fbff;
  --text: #0f1f34;
  --muted: #52637d;
  --border: #d7e1ed;
  --primary: #0d6efd;
  --primary-dark: #0a4fb4;
  --danger: #b12c2c;
  --danger-bg: #ffe8e8;
  --ok: #127c3a;
  --warn: #8c5a00;
  --warn-bg: #fff4dd;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: "Segoe UI", "Noto Sans", Arial, sans-serif;
  --app-shell-max: 1180px;
  --rail-divider-color: #e5e7eb;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--text);
  font-family: var(--sans);
  background:
    radial-gradient(circle at 10% -20%, #dce8ff 0%, transparent 45%),
    radial-gradient(circle at 95% 0%, #e9f7ff 0%, transparent 40%),
    var(--bg);
}

.hero {
  padding-block: 1.8rem 0.9rem;
}

.brand {
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  color: var(--primary);
  font-weight: 800;
}

.hero h1 {
  margin: 0.35rem 0 0;
  font-size: clamp(1.8rem, 3.5vw, 2.4rem);
}

.subtitle {
  margin: 0.5rem 0 0;
  color: var(--muted);
  max-width: 780px;
}

.layout {
  margin: 0 auto;
  padding-bottom: 2rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
}

@media (min-width: 1120px) {
  .layout {
    grid-template-columns: minmax(0, 1fr) 360px;
    align-items: stretch;
    --panel-height: clamp(620px, calc(100vh - 180px), 860px);
  }

  .tablePanel,
  .optionsPanel {
    height: var(--panel-height);
  }
}

button,
select,
input[type="number"],
input[type="text"] {
  font: inherit;
}

button {
  border: 1px solid #b7c7dd;
  border-radius: 8px;
  padding: 0.55rem 0.8rem;
  background: #ffffff;
  color: #22354f;
  cursor: pointer;
}

button:hover:not(:disabled) { background: #f5f8fc; }
button:disabled { opacity: 0.55; cursor: not-allowed; }

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(13, 110, 253, 0.28);
  outline-offset: 2px;
}

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

button.primary:hover:not(:disabled) { background: var(--primary-dark); }

button.danger {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: #f3b5b5;
}

.tablePanel,
.optionsPanel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.hidden { display: none !important; }

.tablePanel {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 620px;
}

.toolbarShell {
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
  padding: 0.65rem 0.75rem 0.75rem;
  display: grid;
  gap: 0.55rem;
}

.modeSwitch {
  display: inline-flex;
  border: 1px solid #c7d6ea;
  border-radius: 999px;
  background: #fff;
  padding: 3px;
  width: fit-content;
}

.modeBtn {
  border: 0;
  border-radius: 999px;
  padding: 0.38rem 0.85rem;
  background: transparent;
  font-weight: 600;
}

.modeBtn.is-active {
  background: #dceaff;
  color: #103f86;
}

.presetBar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.45rem;
}

.presetChip {
  text-align: left;
  min-height: 64px;
  padding: 0.5rem 0.6rem;
  border-radius: 10px;
  border: 1px solid #c9d8eb;
  background: #fff;
  display: grid;
  gap: 0.1rem;
}

.presetChip .presetTitle {
  font-weight: 700;
  color: #163f7f;
}

.presetChip .presetHelp {
  font-size: 0.76rem;
  line-height: 1.25;
  color: var(--muted);
}

.presetChip.is-active {
  border-color: #7ca9ea;
  background: #eaf2ff;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0;
  border: 0;
  background: transparent;
}

.toolbarGroup {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.toolbarGroup--export {
  margin-inline-start: auto;
}

.simpleLocalHint {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.runSummary {
  border: 1px solid #bfd8c7;
  background: #effaf2;
  color: #1c5f31;
  border-radius: 10px;
  padding: 0.45rem 0.6rem;
  font-size: 0.84rem;
}

.altToolCta {
  border: 1px solid #c9d9ee;
  background: #f3f8ff;
  color: #214f8f;
  border-radius: 10px;
  padding: 0.42rem 0.6rem;
  font-size: 0.82rem;
}

.altToolCta a {
  color: #0d57b8;
  font-weight: 600;
}

.dropHint {
  padding: 0.65rem 0.8rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.queueTools {
  border-bottom: 1px solid var(--border);
  padding: 0.58rem 0.8rem;
  display: grid;
  gap: 0.5rem;
  background: #fdfefe;
}

.filterBar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.38rem;
}

.filterChip {
  border: 1px solid #c7d6ea;
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  background: #fff;
  font-size: 0.78rem;
}

.filterChip.is-active {
  background: #e7f0ff;
  border-color: #84aae1;
  color: #1f4a88;
}

.queueActions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.42rem;
  align-items: center;
}

.queueActions select {
  width: auto;
  min-width: 175px;
  font-size: 0.84rem;
}

.hintText {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.pill {
  border: 1px solid #d4e4ff;
  background: #edf4ff;
  color: #1a4ea6;
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
  font-size: 0.78rem;
  white-space: nowrap;
}

.pill.warn {
  color: var(--warn);
  border-color: #ffe2ab;
  background: var(--warn-bg);
}

.pill.ok {
  color: var(--ok);
  border-color: #b8e9c9;
  background: #eaf9f0;
}

.kbd {
  font-family: var(--mono);
  border: 1px solid #c8d6ea;
  border-radius: 6px;
  padding: 1px 5px;
  background: #fff;
}

.tableWrap {
  flex: 1;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f7fafe;
  text-align: left;
  border-bottom: 1px solid var(--border);
  padding: 0.6rem;
  cursor: pointer;
  white-space: nowrap;
}

thead th .sort {
  color: #6a7f9c;
  margin-left: 0.35rem;
}

tbody td {
  border-bottom: 1px solid #edf2f8;
  padding: 0.55rem 0.6rem;
}

tbody tr:hover { background: #f8fbff; }

tbody tr.selected {
  background: #eaf2ff;
  outline: 1px solid #d5e4ff;
}

.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.status-ok { color: var(--ok); }
.status-warn { color: var(--warn); }
.status-err { color: var(--danger); }

.nameCell {
  display: grid;
  gap: 0.26rem;
}

.nameMain {
  line-height: 1.2;
  word-break: break-word;
}

.badgeRow {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.miniBadge {
  border-radius: 999px;
  border: 1px solid #cad9ec;
  background: #edf4ff;
  color: #224f8f;
  font-size: 0.72rem;
  line-height: 1;
  padding: 0.2rem 0.46rem;
}

.miniBadge.warn {
  color: #6a4500;
  border-color: #ffdca1;
  background: #fff4df;
}

.miniBadge.ok {
  color: #1e6a35;
  border-color: #b9e5c8;
  background: #e9f9ef;
}

.miniBadge.err {
  color: #8f2f2f;
  border-color: #f1c2c2;
  background: #fff0f0;
}

.rowCta a {
  color: #125bb7;
  font-size: 0.78rem;
  text-decoration: none;
}

.rowCta a:hover,
.rowCta a:focus-visible {
  text-decoration: underline;
}

.statusBar {
  padding: 0.65rem 0.8rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

#statusText { color: var(--muted); flex: 1; min-width: 260px; }
progress { width: 260px; height: 12px; }

.optionsPanel {
  padding: 0.9rem;
  display: grid;
  gap: 0.6rem;
  align-content: start;
  overflow: auto;
}

.optionsPanel h2 {
  margin: 0.25rem 0;
  font-size: 1rem;
}

.group {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.7rem;
  background: var(--surface-soft);
}

.row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0.45rem 0;
}

.label-with-tip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex: 0 0 auto;
}

.info-tip {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 1px solid #b7c7dd;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.74rem;
  color: #27466b;
  background: #f5f8fc;
  cursor: help;
  user-select: none;
}

.row.stacked {
  display: grid;
  gap: 0.35rem;
}

.row > * { flex: 1; }
.row .tight { flex: 0 0 auto; }
.row.split > * { flex: 1; }

.fieldHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.fieldInline {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.fieldInline input[type="number"] {
  max-width: 96px;
}

label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: #20324c;
  font-size: 0.9rem;
}

.help {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

.help.warnText {
  color: #8c5a00;
}

input[type="range"] { width: 100%; }

input[type="text"],
input[type="number"],
select {
  width: 100%;
  border: 1px solid #c4d3e5;
  border-radius: 8px;
  padding: 0.48rem 0.55rem;
  background: #fff;
}

input:focus,
select:focus {
  border-color: var(--primary);
  outline: 2px solid #d1e2ff;
}

details {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem;
  background: #fff;
}

summary { cursor: pointer; }

pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.76rem;
  color: #34506f;
  font-family: var(--mono);
}

.modal.hidden { display: none; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 29, 46, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 20;
}

.modal .card {
  width: min(980px, 100%);
  max-height: 90vh;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  display: flex;
  flex-direction: column;
}

.modal .card > header {
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 0.85rem;
}

.modal .card .content {
  padding: 0.8rem;
  overflow: auto;
}

.previewTop {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.previewTop #pvBg { max-width: 170px; }
.previewTop #pvSplit { width: 140px; }

.previewWrap {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: auto;
  position: relative;
  height: min(68vh, 700px);
  background: #f0f3f8;
}

.previewWrap.checker {
  background:
    linear-gradient(45deg, rgba(0,0,0,0.03) 25%, transparent 25%) 0 0/24px 24px,
    linear-gradient(-45deg, rgba(0,0,0,0.03) 25%, transparent 25%) 0 12px/24px 24px,
    linear-gradient(45deg, transparent 75%, rgba(0,0,0,0.03) 75%) 12px -12px/24px 24px,
    linear-gradient(-45deg, transparent 75%, rgba(0,0,0,0.03) 75%) 12px 0/24px 24px,
    #f5f8fc;
}

.previewWrap.white { background: #ffffff; }
.previewWrap.black { background: #000000; }

#pvCanvas {
  image-rendering: pixelated;
  transform-origin: top left;
  display: block;
}

.previewCompare {
  position: relative;
  width: fit-content;
}

.pvLayer {
  image-rendering: pixelated;
  transform-origin: top left;
  display: block;
}

.pvAfterClip {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.pvDivider {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.35);
  pointer-events: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: var(--mono);
  background: rgba(0, 0, 0, 0.38);
}

.overlay.hidden { display: none; }

.prefLabel { min-width: 180px; }

.global-note {
  margin: 0 auto;
  padding-bottom: 1.1rem;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.guide-layout {
  margin: 0 auto 1.4rem;
  display: grid;
  gap: 0.8rem;
  grid-template-columns: 1fr;
}

@media (min-width: 840px) {
  .guide-layout {
    grid-template-columns: 1fr 1fr;
  }
}

.guide-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #ffffff;
  padding: 0.85rem;
}

.guide-card h2 {
  margin: 0;
  font-size: 1rem;
}

.guide-card p,
.guide-card li {
  color: var(--muted);
  line-height: 1.55;
}

.guide-card p {
  margin: 0.55rem 0 0;
}

.guide-card ul,
.guide-card ol {
  margin: 0.55rem 0 0;
  padding-left: 1.15rem;
}

.faq-card details {
  margin-top: 0.5rem;
  border: 1px solid #dce7f7;
  border-radius: 10px;
  padding: 0.52rem 0.62rem;
  background: #f9fcff;
}

.faq-card summary {
  cursor: pointer;
  color: #24466f;
  font-weight: 600;
}

.faq-card details p {
  margin-top: 0.42rem;
}

.updated-at {
  margin-top: 0.65rem;
  font-size: 0.85rem;
}

@media (max-width: 720px) {
  .toolbar { position: static; }
  .toolbarGroup {
    width: 100%;
  }
  .toolbarGroup--run,
  .toolbarGroup--export,
  .toolbarGroup--advanced {
    margin-inline-start: 0;
  }
  .dropHint { align-items: flex-start; }
  .presetBar {
    grid-template-columns: 1fr 1fr;
  }
  .queueActions {
    flex-direction: column;
    align-items: stretch;
  }
  .queueActions select {
    width: 100%;
  }
}

body.mode-simple .optionsPanel { display: none; }
body.mode-simple .layout {
  grid-template-columns: minmax(0, 1fr) !important;
}

body.mode-simple .toolbarGroup--export {
  margin-inline-start: 0;
}

body.mode-simple [data-advanced-only] {
  display: none !important;
}

.tool-footer {
  margin-top: 56px;
  padding-bottom: 2rem;
}

.tool-footer__inner {
  text-align: left;
}

.tool-footer__nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-bottom: 14px;
}

.tool-footer__nav a {
  color: inherit;
  text-decoration: none;
}

.tool-footer__nav a:hover,
.tool-footer__nav a:focus-visible {
  text-decoration: underline;
}

.tool-footer__meta,
.tool-footer__note {
  margin: 0 0 10px;
  line-height: 1.65;
  font-size: 0.95rem;
  color: #4b5563;
}
