:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-soft: #f0f4f8;
  --text: #1f2933;
  --muted: #65758b;
  --line: #d8e0ea;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --accent-soft: #d9f3ef;
  --danger: #b42318;
  --shadow: 0 18px 45px rgba(31, 41, 51, 0.08);
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: #fbfcfe;
  padding: 22px 18px;
}

.brand {
  display: grid;
  grid-template-columns: 42px 1fr;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 17px;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.tool-search {
  margin: 28px 0 16px;
}

.tool-search label,
.field label,
.output-title {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  margin-bottom: 8px;
}

.tool-search input,
.field input,
.field textarea,
.select-like {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  outline: 0;
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease;
}

.tool-search input,
.field input,
.select-like {
  min-height: 42px;
  padding: 9px 12px;
}

.field textarea {
  min-height: 220px;
  resize: vertical;
  padding: 12px;
  line-height: 1.58;
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 14px;
}

.tool-search input:focus,
.field input:focus,
.field textarea:focus,
.select-like:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.tool-nav {
  display: grid;
  gap: 8px;
}

.nav-button {
  display: grid;
  grid-template-columns: 32px 1fr;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  padding: 8px 10px;
  text-align: left;
}

.nav-button:hover {
  background: var(--panel-soft);
}

.nav-button.is-active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 7px;
  background: #e8edf3;
  font-weight: 800;
}

.nav-button.is-active .nav-icon {
  background: var(--accent);
  color: #fff;
}

.nav-meta strong,
.nav-meta span {
  display: block;
}

.nav-meta strong {
  font-size: 14px;
}

.nav-meta span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.main {
  min-width: 0;
  padding: 30px clamp(18px, 3vw, 42px);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 24px;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(26px, 3vw, 38px);
  line-height: 1.15;
  letter-spacing: 0;
}

.topbar p {
  margin: 10px 0 0;
  max-width: 760px;
  color: var(--muted);
  line-height: 1.7;
}

.ghost-button,
.primary-button,
.secondary-button,
.small-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border-radius: var(--radius);
  padding: 8px 13px;
  font-weight: 700;
  white-space: nowrap;
}

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

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

.secondary-button,
.ghost-button,
.small-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

.secondary-button:hover,
.ghost-button:hover,
.small-button:hover {
  border-color: #b9c6d4;
  background: #f8fafc;
}

.tool-mount {
  max-width: 1520px;
}

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

.tool-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
}

.tool-head h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.25;
  letter-spacing: 0;
}

.tool-head p {
  margin: 7px 0 0;
  color: var(--muted);
  line-height: 1.65;
}

.tool-body {
  padding: 24px;
}

.tool-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
}

.field {
  min-width: 0;
}

.field-toolbar,
.result-toolbar,
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.field-toolbar {
  justify-content: space-between;
  margin-bottom: 8px;
}

.result-toolbar {
  justify-content: space-between;
  margin-bottom: 10px;
}

.button-row {
  margin-top: 12px;
}

.output-box {
  min-height: 220px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0f172a;
  color: #e5edf7;
  padding: 12px;
  line-height: 1.58;
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}

.hint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.error-text {
  color: var(--danger);
  font-size: 13px;
  line-height: 1.55;
  min-height: 20px;
  margin-top: 8px;
}

.timestamp-layout {
  display: grid;
  gap: 22px;
}

.conversion-block {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  background: #fff;
}

.conversion-block h3 {
  margin: 0 0 14px;
  font-size: 17px;
  letter-spacing: 0;
}

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

.timestamp-result {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.result-line {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfe;
  padding: 10px;
}

.result-line b {
  color: var(--muted);
  font-size: 13px;
}

.result-line code {
  overflow-wrap: anywhere;
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.diff-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0;
}

.diff-pill {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 700;
}

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

.diff-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.diff-side-toolbar {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
}

.diff-side-toolbar > div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.diff-merge-host {
  min-height: 560px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.diff-loading {
  padding: 30px;
  color: var(--muted);
  text-align: center;
}

.diff-merge-host .cm-mergeView {
  height: 560px;
}

.diff-merge-host .CodeMirror {
  height: 560px;
  font-size: 13px;
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.diff-merge-host .CodeMirror-merge,
.diff-merge-host .CodeMirror-merge-pane,
.diff-merge-host .CodeMirror-merge .CodeMirror {
  height: 560px;
}

.diff-merge-host .CodeMirror-merge-gap {
  background: #f8fafc;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

.diff-merge-host .CodeMirror-merge-r-chunk {
  background-color: #ecfdf3;
}

.diff-merge-host .CodeMirror-merge-l-chunk {
  background-color: #fff1f3;
}

.diff-result-toolbar {
  margin-top: 16px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  transform: translateY(16px);
  opacity: 0;
  pointer-events: none;
  max-width: min(360px, calc(100vw - 40px));
  border-radius: var(--radius);
  background: #172033;
  color: #fff;
  padding: 12px 14px;
  box-shadow: 0 16px 38px rgba(15, 23, 42, 0.22);
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 34px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
    padding: 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .tool-nav {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }

  .main {
    padding: 22px 16px 30px;
  }

  .topbar,
  .tool-head {
    display: grid;
  }

  .tool-grid,
  .inline-grid {
    grid-template-columns: 1fr;
  }

  .diff-side-toolbar {
    display: grid;
  }

  .diff-merge-host,
  .diff-merge-host .cm-mergeView,
  .diff-merge-host .CodeMirror,
  .diff-merge-host .CodeMirror-merge,
  .diff-merge-host .CodeMirror-merge-pane {
    height: 480px;
    min-height: 480px;
  }

  .result-line {
    grid-template-columns: 1fr;
  }
}
