/* ============================================================
   MyBatis 工具站 — 共用样式
   主题：深色工作台；主色取 MyBatis 品牌红；等宽字体为身份字体
   ============================================================ */

:root {
  --bg: #14171e;
  --panel: #1c212b;
  --panel-input: #232936;
  --line: #2c3442;
  --line-strong: #3a4454;
  --text: #e8ebf1;
  --muted: #8f99ab;
  --accent: #e0413e;        /* 主操作（MyBatis 红） */
  --accent-hover: #c93633;
  --teal: #3fa7ad;          /* 次操作 */
  --teal-hover: #359298;
  --code: #a5d6a7;          /* 结果区代码文字 */
  --code-dim: #6f8f72;
  --danger: #e0413e;
  --danger-bg: rgba(224, 65, 62, 0.08);
  --radius: 10px;
  --mono: Consolas, "Courier New", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

::selection {
  background: rgba(224, 65, 62, 0.35);
}

a {
  color: inherit;
}

button {
  font: inherit;
}

:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

/* ---------- 顶栏 ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.75rem clamp(1rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--line);
  background: rgba(20, 23, 30, 0.92);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(6px);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  text-decoration: none;
  min-height: 44px;
  align-items: center;
}

.brand-tag {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--accent);
  letter-spacing: -0.02em;
}

.brand-tag::after {
  content: "▌";
  color: var(--accent);
  opacity: 0.7;
  margin-left: 2px;
  animation: caret 1.4s step-end infinite;
}

@keyframes caret {
  50% { opacity: 0; }
}

.brand-sub {
  color: var(--muted);
  font-size: 0.85rem;
}

.nav {
  display: flex;
  gap: 0.25rem;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 1rem;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.95rem;
  transition: color 0.15s, background-color 0.15s;
}

.nav-link:hover {
  color: var(--text);
  background: var(--panel-input);
}

.nav-link.active {
  color: var(--accent);
  background: var(--panel);
  font-weight: 600;
}

/* ---------- 页面骨架 ---------- */

.layout {
  max-width: 1280px;
  margin: 0 auto;
  padding: clamp(1.25rem, 3vw, 2.5rem) clamp(1rem, 4vw, 2.5rem) 4rem;
}

.page-title {
  font-family: var(--mono);
  font-size: clamp(1.3rem, 2.5vw, 1.7rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 0.25rem;
}

.page-desc {
  color: var(--muted);
  margin: 0 0 1.75rem;
  font-size: 0.95rem;
}

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  align-items: start;
}

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

/* ---------- 面板 ---------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(1rem, 2.5vw, 1.5rem);
  min-width: 0;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.9rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--line);
}

.panel-title {
  font-family: var(--mono);
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
}

.panel-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ---------- 表单 ---------- */

.field {
  margin-bottom: 1rem;
}

.field-grow {
  flex: 1 1 220px;
}

.field-row {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
}

.field-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.4rem;
}

.field-hint {
  font-size: 0.78rem;
  color: var(--muted);
}

.field-row .field-hint {
  margin-left: auto;
}

.code-area {
  width: 100%;
  min-height: 44px;
  padding: 0.75rem;
  background: var(--panel-input);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.55;
  resize: vertical;
  transition: border-color 0.15s;
}

.code-area:focus {
  outline: none;
  border-color: var(--teal);
}

.select {
  width: 100%;
  min-height: 44px;
  padding: 0 0.75rem;
  background: var(--panel-input);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.select:focus {
  outline: none;
  border-color: var(--teal);
}

/* ---------- 按钮 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 1.1rem;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.btn-strong {
  padding: 0 1.6rem;
  font-size: 0.95rem;
}

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

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

.btn-accent {
  background: var(--teal);
  color: #102224;
}

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

.btn-ghost {
  background: transparent;
  border-color: var(--line-strong);
  color: var(--text);
}

.btn-ghost:hover {
  background: var(--panel-input);
  border-color: var(--line-strong);
}

.btn-danger-ghost {
  background: var(--danger-bg);
  border-color: rgba(224, 65, 62, 0.35);
  color: var(--danger);
}

.btn-danger-ghost:hover {
  background: rgba(224, 65, 62, 0.16);
}

.btn[hidden] {
  display: none;
}

/* ---------- 结果区 ---------- */

.result-box {
  background: #10131a;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--code);
  font-family: var(--mono);
  font-size: 0.84rem;
  line-height: 1.6;
  padding: 1rem;
  min-height: 420px;
  max-height: 70vh;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.error-alert {
  margin-top: 0.9rem;
  padding: 0.75rem 1rem;
  border: 1px solid rgba(224, 65, 62, 0.4);
  border-radius: 8px;
  background: var(--danger-bg);
  color: #f0a5a3;
  font-size: 0.9rem;
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
  flex-wrap: wrap;
}

.error-alert[hidden] {
  display: none;
}

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

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 2rem;
  transform: translateX(-50%) translateY(8px);
  background: #262e3c;
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0.55rem 1.1rem;
  font-size: 0.88rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
}

.toast.toast-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- 其他 ---------- */

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 480px) {
  .topbar {
    justify-content: center;
  }

  .panel-actions .btn {
    padding: 0 0.8rem;
    font-size: 0.85rem;
  }
}
