:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #10233f;
  --muted: #586d89;
  --line: #cfdae8;
  --brand: #0d6efd;
  --brand-ink: #ffffff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: radial-gradient(circle at top right, #ddefff, var(--bg) 55%);
  color: var(--text);
}

.app {
  max-width: min(1680px, calc(100vw - 24px));
  margin: 0 auto;
  padding: 24px 16px 40px;
}

.app.home-app {
  max-width: min(1680px, calc(100vw - 24px));
}

.app.home-app .topbar-inner {
  max-width: min(1680px, calc(100vw - 24px));
}

.app.home-app .hero p {
  max-width: 1120px;
}

.topbar {
  margin: -24px -16px 0;
  padding: 0 16px;
  background: #fff;
  border-bottom: 1px solid #d7ddea;
}

.topbar-inner {
  max-width: min(1680px, calc(100vw - 24px));
  margin: 0 auto;
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  position: relative;
  width: 100%;
}


.brand {
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: 0.2px;
}

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

.brand-logo {
  display: block;
  height: 48px;
  width: auto;
}

.topnav {
  display: flex;
  gap: 18px;
}

.topnav a {
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
}

.topnav-tools {
  gap: 10px;
  flex-wrap: wrap;
}

.nav-dropdown {
  position: relative;
}

.nav-trigger {
  border: 0;
  background: transparent;
  padding: 9px 12px;
  font-weight: 700;
  letter-spacing: 0.2px;
  color: #16263f;
}

.nav-trigger .chev {
  margin-left: 7px;
  font-size: 0.8rem;
}

.nav-trigger.active {
  color: #cf2d2d;
}

.dropdown-menu {
  position: fixed;
  top: 92px;
  left: 0;
  width: min(1100px, calc(100vw - 16px));
  max-width: calc(100vw - 16px);
  box-sizing: border-box;
  background: #f2f4f8;
  border: 1px solid #d4dbe7;
  border-radius: 14px;
  padding: 16px;
  display: none;
  z-index: 50;
  box-shadow: 0 16px 36px rgba(20, 34, 56, 0.14);
}

.dropdown-menu::before {
  content: "";
  position: absolute;
  top: -8px;
  left: var(--notch-left, 40px);
  width: 13px;
  height: 13px;
  background: #f2f4f8;
  border-left: 1px solid #d4dbe7;
  border-top: 1px solid #d4dbe7;
  transform: translateX(-50%) rotate(45deg);
}

.nav-dropdown.open .dropdown-menu {
  display: block;
}

.dropdown-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px 20px;
}

.dropdown-col h4 {
  margin: 0 0 12px;
  font-size: clamp(0.92rem, 1.05vw, 1.15rem);
  color: #666b76;
  font-weight: 800;
}

.dropdown-col ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 7px;
}

.dropdown-col a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 9px;
  border-radius: 10px;
  color: #1f2d44;
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color 120ms ease;
}

.dropdown-col a.active {
  color: #cf2d2d;
}

.dropdown-col a:hover,
.dropdown-col a:focus-visible {
  background: #e5e8ef;
  color: #16263f;
}

.nav-dropdown.open .nav-trigger {
  color: #cf2d2d;
}


.tool-name {
  font-size: 0.9rem;
  line-height: 1.2;
}

.tool-icon {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  flex: 0 0 22px;
  position: relative;
}

.tool-icon::before,
.tool-icon::after {
  content: "";
  position: absolute;
  border-radius: 2px;
}

.tool-icon::before {
  width: 8px;
  height: 8px;
  left: 3px;
  top: 3px;
  background: rgba(255, 255, 255, 0.65);
}

.tool-icon::after {
  width: 8px;
  height: 8px;
  right: 3px;
  bottom: 3px;
  background: rgba(255, 255, 255, 0.95);
}

.icon-gold {
  background: #f4c528;
}

.icon-blue {
  background: #5d83cc;
}

.icon-orange {
  background: #ef7b58;
}

.icon-green {
  background: #6eb06f;
}

.icon-slate {
  background: #5f7fa8;
}

.icon-rose {
  background: #b3759f;
}

.hero {
  margin-top: 18px;
  padding: 32px 18px;
  border: 1px solid #d6dfec;
  border-radius: 16px;
  background: linear-gradient(140deg, #f3f7ff, #eef2f8);
}

.hero h1 {
  margin: 0;
  font-size: clamp(1.6rem, 3.3vw, 2.6rem);
  text-align: center;
}

.hero p {
  margin: 14px auto 0;
  max-width: 880px;
  text-align: center;
  color: var(--muted);
  font-size: 1.03rem;
}

.category-section {
  margin-top: 18px;
}

.category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.category-tab {
  border: 1px solid #cad6e8;
  background: #f7f9fd;
  border-radius: 999px;
  padding: 9px 14px;
  font-weight: 700;
}

.category-tab.active {
  border-color: #1f2a3c;
  background: #1f2a3c;
  color: #fff;
}

.cards-section {
  margin-top: 16px;
}

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

.tool-card {
  display: block;
  border: 1px solid #d4deeb;
  border-radius: 14px;
  background: #f7f9fd;
  padding: 14px;
  cursor: pointer;
  text-align: left;
  color: inherit;
  text-decoration: none;
}

.tool-card:hover {
  border-color: #9db2d4;
  transform: translateY(-1px);
}

.tool-card h3 {
  margin: 0;
  font-size: 1.16rem;
}

.tool-card p {
  margin: 9px 0 0;
  color: var(--muted);
}

.tool-card small {
  display: inline-block;
  margin-top: 10px;
  color: #37537d;
  font-weight: 700;
}

.tool-card.disabled {
  cursor: default;
  opacity: 0.8;
}

.tools-empty {
  color: var(--muted);
  margin: 8px 0 0;
}

.workspace-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
  margin-bottom: 10px;
}

.workspace-head h2 {
  margin: 0;
  font-size: 1.35rem;
}

.tool-picker label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
}

select,
textarea,
button {
  font: inherit;
}

select {
  width: 100%;
  max-width: 360px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
}

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

label {
  display: block;
  font-weight: 600;
}

textarea {
  width: 100%;
  min-height: 230px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  resize: vertical;
  background: #fff;
  font-family: Consolas, Menlo, monospace;
  font-size: 0.95rem;
  line-height: 1.45;
}

.line-editor {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
  height: 230px;
}

.line-gutter {
  margin: 0;
  padding: 12px 8px;
  border-right: 1px solid var(--line);
  background: #f4f7fc;
  color: #7c8ca5;
  text-align: right;
  user-select: none;
  white-space: pre;
  overflow: hidden;
  font-family: Consolas, Menlo, monospace;
  font-size: 0.95rem;
  line-height: 1.45;
}

.line-content {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.syntax-layer {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 12px;
  overflow: hidden;
  pointer-events: none;
  white-space: pre;
  font-family: Consolas, Menlo, monospace;
  font-size: 0.95rem;
  line-height: 1.45;
  color: #d6deeb;
  z-index: 1;
}

textarea.with-lines {
  border: 0;
  border-radius: 0;
  margin: 0;
  white-space: pre;
  overflow-wrap: normal;
  word-break: normal;
  min-height: 0;
  height: 100%;
  overflow: auto;
  position: relative;
  z-index: 2;
}

textarea.with-lines.syntax-enabled {
  color: transparent;
  background-color: transparent;
  caret-color: #d6deeb;
}

textarea.issue-line::selection {
  background: transparent;
  color: #ff5f67;
}

textarea.issue-line::-moz-selection {
  background: transparent;
  color: #ff5f67;
}

textarea.with-lines.syntax-enabled.issue-line::selection {
  color: transparent;
}

textarea.with-lines.syntax-enabled.issue-line::-moz-selection {
  color: transparent;
}

.json-preview-view {
  border: 1px solid #1f3556;
  border-radius: 8px;
  background: #0b1220;
  min-height: 230px;
  max-height: 520px;
  overflow: auto;
}

.json-pre {
  margin: 0;
  padding: 12px;
  white-space: pre;
  font-family: Consolas, Menlo, monospace;
  font-size: 0.95rem;
  line-height: 1.45;
  color: #d6deeb;
}

.json-pre.plain {
  color: #c7d2e5;
}

.json-tok-key {
  color: #22d3a4;
}

.json-tok-string {
  color: #6ea8fe;
}

.json-tok-num {
  color: #f9c56d;
}

.json-tok-bool {
  color: #f38ba8;
}

.json-tok-null {
  color: #c8a8ff;
}

.json-tok-punct {
  color: #e2e8f5;
}

.yaml-tok-key {
  color: #22d3a4;
}

.yaml-tok-value {
  color: #6ea8fe;
}

.yaml-tok-num {
  color: #f9c56d;
}

.yaml-tok-bool {
  color: #6ea8fe;
}

.yaml-tok-null {
  color: #c8a8ff;
}

.yaml-tok-punct {
  color: #e2e8f5;
}

.yaml-tok-comment {
  color: #7f93b8;
}

.syntax-issue-line,
.syntax-issue-line * {
  text-decoration-line: underline;
  text-decoration-style: wavy;
  text-decoration-color: #ff5f67;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 2px;
}

body.json-theme .input-wrap .line-editor,
body.json-theme .output-wrap .line-editor {
  border-color: #1f3556;
  background: #0b1220;
}

body.json-theme .input-wrap .line-gutter,
body.json-theme .output-wrap .line-gutter {
  border-right-color: #1f3556;
  background: #121b2f;
  color: #7fa2d6;
}

body.json-theme .input-wrap textarea,
body.json-theme .output-wrap textarea {
  background-color: #0b1220;
  color: #d6deeb;
}

body.json-theme .input-wrap textarea.with-lines.syntax-enabled,
body.json-theme .output-wrap textarea.with-lines.syntax-enabled {
  background-color: transparent;
  color: transparent;
}

body.editor-theme-dark textarea,
body.editor-theme-dark .line-editor {
  background: #0b1220;
  border-color: #2d466f;
  color: #dbe8ff;
}

body.editor-theme-dark .line-gutter {
  background: #121f34;
  border-right-color: #2d466f;
  color: #8aa8d6;
}

body.editor-theme-dark .syntax-layer {
  color: #dbe8ff;
}

body.editor-theme-dark textarea.with-lines.syntax-enabled {
  caret-color: #dbe8ff;
}

body.editor-theme-dark .csv-grid-view {
  background: #0b1220;
  border-color: #2d466f;
}

body.editor-theme-dark .csv-grid-table th,
body.editor-theme-dark .csv-grid-table td {
  border-color: #2d466f;
}

body.editor-theme-dark .csv-grid-table th {
  background: #14233a;
}

body.editor-theme-light .input-wrap .line-editor,
body.editor-theme-light .output-wrap .line-editor {
  border-color: var(--line);
  background: #fff;
}

body.editor-theme-light .input-wrap .line-gutter,
body.editor-theme-light .output-wrap .line-gutter {
  border-right-color: var(--line);
  background: #f4f7fc;
  color: #7c8ca5;
}

body.editor-theme-light .input-wrap textarea,
body.editor-theme-light .output-wrap textarea {
  background: #fff;
  color: var(--text);
}

body.editor-theme-light .syntax-layer {
  color: #20324f;
}

body.editor-theme-light textarea.with-lines.syntax-enabled {
  background-color: transparent;
  color: transparent;
  caret-color: #20324f;
}

.line-editor.csv-grid-mode {
  grid-template-columns: 48px minmax(0, 1fr);
}

.line-editor.csv-grid-mode .line-content {
  display: none;
}

.line-gutter.csv-gutter {
  padding: 0;
  white-space: normal;
  position: relative;
}

.line-gutter.csv-gutter .csv-gutter-canvas {
  position: relative;
  width: 100%;
}

.line-gutter.csv-gutter .csv-gutter-row {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 8px;
  box-sizing: border-box;
  line-height: 1.45;
}

.line-editor.csv-grid-mode .csv-grid-view {
  grid-column: 2;
  grid-row: 1;
  border: 0;
  border-radius: 0;
  height: 100%;
  max-height: none;
  min-height: 0;
}

.input-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.io-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.editor-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 12px 0;
}

.hidden {
  display: none;
}

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
}

.mini {
  padding: 4px 8px;
  font-size: 0.82rem;
  background: #f8fbff;
}

#runBtn {
  border-color: var(--brand);
  background: var(--brand);
  color: var(--brand-ink);
}

button.ghost {
  background: #f8fbff;
}

#status {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.9rem;
}

.auto-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
}

.editor-theme-toggle {
  white-space: nowrap;
}

.textcase-toolbar {
  margin: 10px 0 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.textcase-toolbar.hidden {
  display: none;
}

.textcase-btn {
  border: 1px solid #5a616b;
  border-radius: 0;
  background: #666;
  color: #fff;
  font-weight: 700;
  padding: 8px 12px;
}

.textcase-btn.active {
  background: #2f6ac8;
  border-color: #2f6ac8;
}

.textcase-btn.utility {
  background: #575c64;
}

.textcase-stats {
  margin: 0 0 10px;
  color: var(--muted);
  font-weight: 600;
}

.textcase-stats.hidden {
  display: none;
}

.panel.diff-mode {
  background: #050f20;
  border-color: #1c2a43;
  color: #dbe8ff;
}

.panel.diff-mode .editor-head label,
.panel.diff-mode #outputLabel {
  color: #f2f7ff;
}

.panel.diff-mode .controls {
  margin-top: 14px;
}

.panel.diff-mode .io-layout {
  grid-template-columns: 1fr;
}

.panel.diff-mode textarea {
  border-color: #1f3556;
  background: #030a18;
  color: #e8f2ff;
}

.panel.diff-mode .line-editor {
  border-color: #1f3556;
  background: #030a18;
}

.panel.diff-mode .line-gutter {
  border-right-color: #1f3556;
  background: #0f1d34;
  color: #7ea1d1;
}

.panel.diff-mode .input-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.panel.diff-mode .input-wrap {
  background: #0d1a30;
  border: 1px solid #1f3556;
  border-radius: 10px;
  padding: 10px;
}

.panel.diff-mode .input-wrap textarea {
  min-height: 250px;
}

.panel.diff-mode .mini {
  border-color: #2b4570;
  background: #152844;
  color: #dbe8ff;
}

.panel.diff-mode #runBtn {
  background: #19355b;
  border-color: #2b4a77;
}

.panel.diff-mode button.ghost {
  background: #122540;
  color: #dbe8ff;
  border-color: #2b4570;
}

.panel.diff-mode #status {
  color: #9dc0ef;
}

.diff-view {
  margin-top: 8px;
  border: 1px solid #1f3556;
  border-radius: 10px;
  overflow: hidden;
  font-family: Consolas, Menlo, monospace;
}

.diff-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.diff-table th,
.diff-table td {
  padding: 6px 8px;
  vertical-align: top;
}

.diff-table th {
  text-align: left;
  background: #152844;
  color: #d7e7ff;
}

.diff-line-num {
  width: 52px;
  color: #7ea1d1;
}

.diff-code {
  white-space: pre-wrap;
  word-break: break-word;
}

.diff-row.same .diff-code {
  background: #06122a;
}

.diff-row.left-only .diff-code.left {
  background: #34141f;
}

.diff-row.right-only .diff-code.right {
  background: #113320;
}

.diff-row.changed .diff-code.left {
  background: #34141f;
}

.diff-row.changed .diff-code.right {
  background: #113320;
}

.diff-row.collapsed .diff-collapsed-cell {
  background: #0f1f38;
  padding: 0;
}

.diff-expand-btn {
  width: 100%;
  border: 0;
  border-radius: 0;
  background: #1b2f4f;
  color: #b8d3f8;
  text-align: left;
  padding: 10px 14px;
  font-family: Consolas, Menlo, monospace;
  font-weight: 700;
}

.diff-expand-btn:hover {
  background: #223a61;
}

.diff-identical {
  padding: 18px;
  border: 1px solid #1f3556;
  border-radius: 10px;
  background: #09172d;
  color: #dbe8ff;
}

.diff-identical h3 {
  margin: 0;
  font-size: 1.05rem;
}

.diff-identical p {
  margin: 8px 0 0;
  color: #a9c4ea;
}

.csv-grid-view {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  max-height: 520px;
  overflow: auto;
}

.csv-grid-wrap {
  min-width: 100%;
}

.csv-grid-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
  font-family: Consolas, Menlo, monospace;
}

.csv-grid-table th,
.csv-grid-table td {
  border: 1px solid #d6deea;
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}

.csv-grid-table th {
  background: #f5f8fc;
  font-weight: 700;
}

.diff-char-del {
  background: #7a2d45;
  border-radius: 2px;
}

.diff-char-add {
  background: #2f7d47;
  border-radius: 2px;
}

@media (max-width: 640px) {
  .app {
    padding: 16px 12px 24px;
  }

  textarea {
    min-height: 180px;
  }

  #status {
    width: 100%;
    margin-left: 0;
  }

  .panel.diff-mode .input-grid {
    grid-template-columns: 1fr;
  }

  .workspace-head {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar {
    margin: -16px -12px 0;
    padding: 0 12px;
  }

  .topbar-inner {
    min-height: 72px;
    align-items: flex-start;
    padding: 8px 0;
  }

  .dropdown-menu {
    width: min(95vw, 720px);
    max-width: min(90vw, 360px);
    padding: 16px;
  }

  .dropdown-menu::before {
    left: 24px;
    transform: rotate(45deg);
  }

  .tool-name {
    font-size: 1rem;
  }
}

@media (min-width: 900px) {
  .tools-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .panel:not(.diff-mode) .io-layout {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
    gap: 16px;
  }

  .panel:not(.diff-mode) .input-wrap textarea,
  .panel:not(.diff-mode) .output-wrap textarea {
    min-height: 460px;
  }

  .panel:not(.diff-mode) .input-wrap .line-editor,
  .panel:not(.diff-mode) .output-wrap .line-editor {
    height: 460px;
  }
}

@media (min-width: 1360px) {
  .app.home-app .tools-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (min-width: 1760px) {
  .app.home-app .tools-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}
