:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f0f4f8;
  --text: #172033;
  --muted: #5c667a;
  --line: #d7dee9;
  --primary: #166a75;
  --primary-strong: #0d4d58;
  --accent: #9a5a12;
  --danger: #b42318;
  --ok: #137333;
  --shadow: 0 10px 26px rgba(27, 39, 59, 0.08);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(22, 106, 117, 0.07), transparent 260px),
    var(--bg);
  font-family: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 64px;
  padding: 10px 28px;
  border-bottom: 1px solid rgba(215, 222, 233, 0.9);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
}

.brand {
  flex: 0 0 auto;
  color: var(--primary-strong);
  font-weight: 800;
  white-space: nowrap;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  overflow: visible;
}

.nav-group {
  position: relative;
  display: inline-flex;
}

.nav-link,
.nav-subitem {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  color: var(--muted);
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
}

.nav-link {
  min-height: 38px;
  padding: 0 12px;
  border-radius: 8px;
}

.nav-link:hover,
.nav-group:hover .nav-trigger,
.nav-group:focus-within .nav-trigger {
  border-color: var(--line);
  color: var(--text);
  background: var(--surface-2);
}

.nav-link.active,
.nav-group:hover .nav-trigger.active,
.nav-group:focus-within .nav-trigger.active {
  border-color: rgba(22, 106, 117, 0.22);
  color: var(--primary-strong);
  background: rgba(22, 106, 117, 0.1);
}

.nav-submenu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 30;
  display: none;
  min-width: 150px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow);
}

.nav-submenu::before {
  content: "";
  position: absolute;
  right: 0;
  bottom: 100%;
  left: 0;
  height: 9px;
}

.nav-group:hover .nav-submenu,
.nav-group:focus-within .nav-submenu {
  display: grid;
  gap: 4px;
}

.nav-subitem {
  justify-content: flex-start;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 6px;
}

.nav-subitem:hover {
  color: var(--text);
  background: var(--surface-2);
}

.nav-subitem.active {
  color: var(--primary-strong);
  background: rgba(22, 106, 117, 0.1);
}

.workspace {
  min-height: calc(100vh - 112px);
  padding: 28px 28px 74px;
}

.tool-shell {
  width: min(1280px, 100%);
  margin: 0 auto;
}

.tool-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.tool-title {
  margin: 0;
  font-size: 28px;
  line-height: 1.2;
}

.tool-desc {
  margin: 8px 0 0;
  color: var(--muted);
}

.status {
  min-height: 24px;
  color: var(--muted);
  font-size: 14px;
  text-align: right;
}

.status.ok {
  color: var(--ok);
}

.status.error {
  color: var(--danger);
}

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

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 48px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
}

.panel-title {
  font-weight: 700;
}

.panel-body {
  padding: 14px;
}

.editor {
  width: 100%;
  min-height: 420px;
  padding: 14px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  color: var(--text);
  background: #fbfcfe;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 14px;
  line-height: 1.55;
}

.editor:focus,
.field:focus,
.select:focus {
  border-color: rgba(22, 106, 117, 0.7);
  box-shadow: 0 0 0 3px rgba(22, 106, 117, 0.12);
}

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

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
}

.button:hover {
  background: var(--surface-2);
}

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

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

.button.accent {
  border-color: rgba(154, 90, 18, 0.35);
  color: #fff;
  background: var(--accent);
}

.field,
.select {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  color: var(--text);
  background: #fbfcfe;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.field-group {
  min-width: 0;
}

.field-group.wide {
  grid-column: span 2;
}

.label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.single-column {
  display: grid;
  gap: 16px;
}

.record {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0px;
  z-index: 20;
  display: grid;
  gap: 4px;
  justify-items: center;
  padding: 8px 16px;
  border: 1px solid rgba(215, 222, 233, 0.9);
  border-right: 0;
  border-left: 0;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  font-size: 13px;
  text-align: center;
}

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

.record a:hover {
  color: var(--primary-strong);
  text-decoration: underline;
}

@media (max-width: 900px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    padding: 12px 16px;
  }

  .workspace {
    padding: 20px 16px 82px;
  }

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

  .status {
    text-align: left;
  }

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

  .field-group.wide {
    grid-column: auto;
  }

  .editor {
    min-height: 280px;
  }
}
