/* ==========================================================================
   开发者工具箱 — 样式表
   纯静态、零外部依赖。字体仅使用系统字体栈。
   ========================================================================== */

/* ---------- 设计令牌：浅色主题（默认） ---------- */
:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --fg: #171717;
  --muted: #4d4d4d;
  --muted-2: #6e6e6e;
  --border: #ebebeb;
  --accent: #0072f5;
  --accent-soft: rgba(0, 114, 245, 0.10);
  --danger: #d92d20;
  --success: #12805c;
  --syntax-key: #0069de;
  --syntax-string: #087a43;
  --syntax-number: #945300;
  --syntax-bool: #7044ad;
  --focus: hsla(212, 100%, 48%, 1);
  --shadow-ring: 0 0 0 1px rgba(0, 0, 0, 0.08);
  --radius: 8px;
  --radius-sm: 6px;

  /* 字体栈（系统字体，无远程字体） */
  --font-sans: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;

  /* 字号阶（7 级） */
  --fs-3xl: 28px;
  --fs-2xl: 20px;
  --fs-lg: 15px;
  --fs-md: 14px;
  --fs-sm: 13px;
  --fs-xs: 12px;
  --fs-2xs: 11px;

  /* 布局 */
  --sidebar-w: 232px;
  --sidebar-collapsed-w: 58px;
  --header-h: 56px;
  --gutter: clamp(16px, 3vw, 32px);

  color-scheme: light;
}

/* ---------- 设计令牌：深色主题（单独定义，非反色） ---------- */
[data-theme="dark"] {
  --bg: #0a0a0a;
  --surface: #111111;
  --surface-2: #171717;
  --fg: #ededed;
  --muted: #a1a1a1;
  --muted-2: #8f8f8f;
  --border: rgba(255, 255, 255, 0.10);
  --accent: #4a9eff;
  --accent-soft: rgba(74, 158, 255, 0.14);
  --danger: #f97066;
  --success: #3dd68c;
  --syntax-key: #4a9eff;
  --syntax-string: #72d59e;
  --syntax-number: #e8ad65;
  --syntax-bool: #bea3ff;
  --shadow-ring: 0 0 0 1px rgba(255, 255, 255, 0.10);

  color-scheme: dark;
}

/* ---------- 基础重置 ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  font-weight: 400;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3,
p,
figure {
  margin: 0;
}

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

.output--break {
  word-break: break-all;
  white-space: pre-wrap;
}

[hidden] {
  display: none !important;
}

/* 可聚焦元素的可见焦点环 */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* 仅屏幕阅读器可见 */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* 跳转到主内容 */
.skip-link {
  position: absolute;
  left: var(--gutter);
  top: 8px;
  z-index: 100;
  transform: translateY(-160%);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-ring);
  color: var(--fg);
  font-size: var(--fs-sm);
  text-decoration: none;
  transition: transform 120ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

/* 回到顶部悬浮按钮 */
.back-top {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 45;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow-ring), 0 6px 18px -8px rgba(0, 0, 0, 0.35);
  color: var(--muted);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.back-top:hover {
  background: var(--surface-2);
  color: var(--fg);
}

.back-top svg {
  transform: rotate(-90deg);
}

.back-top:active {
  transform: translateY(1px);
}

/* ==========================================================================
   顶部条
   ========================================================================== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--header-h);
  padding: 0 var(--gutter);
  background: var(--bg);
  box-shadow: 0 0 0 1px var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.brand:hover .brand__name {
  color: var(--accent);
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  box-shadow: var(--shadow-ring);
  color: var(--fg);
  flex: none;
}

.brand__name {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-weight: 500;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand__sub {
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted-2);
  white-space: nowrap;
}

.header__spacer {
  flex: 1 1 auto;
  min-width: 0;
}

.header__tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 顶部条里的快捷键提示（桌面可见） */
.kbd-hint {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: transparent;
  box-shadow: var(--shadow-ring);
  color: var(--muted);
  font-size: var(--fs-xs);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.kbd-hint:hover {
  background: var(--surface-2);
  color: var(--fg);
}

.kbd-hint:active {
  transform: translateY(1px);
}

.kbd {
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  letter-spacing: 0.06em;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--surface-2);
  box-shadow: var(--shadow-ring);
  color: var(--muted);
}

/* 图标按钮 */
.icon-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  box-shadow: var(--shadow-ring);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--fg);
}

.icon-btn:active {
  transform: translateY(1px);
}

.icon-btn[aria-pressed="true"],
.icon-btn.is-on {
  background: var(--accent-soft);
  color: var(--accent);
}

/* ==========================================================================
   骨架布局
   ========================================================================== */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  gap: 0;
  max-width: 1560px;
  margin: 0 auto;
  padding: 0 var(--gutter);
  align-items: start;
  transition: grid-template-columns 160ms ease;
}

.app-shell.is-sidebar-collapsed {
  grid-template-columns: var(--sidebar-collapsed-w) minmax(0, 1fr);
}

/* ---------- 侧边导航 ---------- */
.sidebar {
  position: sticky;
  top: var(--header-h);
  align-self: start;
  max-height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 16px 20px 24px 0;
  border-right: 0;
  z-index: 30;
}

.sidebar__actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.sidebar__collapse {
  display: grid;
}

.sidebar__collapse svg {
  transition: transform 160ms ease;
}

.app-shell.is-sidebar-collapsed .sidebar {
  overflow-x: hidden;
  padding-right: 10px;
}

.app-shell.is-sidebar-collapsed .sidebar__collapse svg {
  transform: scaleX(-1);
}

.app-shell.is-sidebar-collapsed .nav__group-toggle,
.app-shell.is-sidebar-collapsed .nav__label {
  display: none;
}

.app-shell.is-sidebar-collapsed .nav__items {
  display: flex !important;
}

.app-shell.is-sidebar-collapsed .nav__list {
  gap: 4px;
}

.app-shell.is-sidebar-collapsed .nav__link {
  justify-content: center;
  padding: 8px;
}

.nav__title {
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  font-weight: 500;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted-2);
  margin: 0 0 10px 10px;
}

.nav__list,
.nav__items {
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav__list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav__items {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav__link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: var(--fs-sm);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.nav__link:hover {
  background: var(--surface-2);
  color: var(--fg);
}

.nav__link:active {
  transform: translateY(1px);
}

/* 当前工具高亮（每屏 accent 使用点 1/2） */
.nav__link[aria-current="true"],
.nav__home[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}
.nav__home { margin-bottom: 16px; }

.nav__icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
}

.nav__label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 移动端抽屉控制 */
.nav-toggle {
  display: none;
}

.nav-backdrop {
  display: none;
}

/* ---------- 主区域 ---------- */
.app-main {
  min-width: 0;
  padding: 28px 0 72px 32px;
}

.app-main__inner {
  max-width: 1040px;
}

.tool {
  display: block;
}

/* 切换工具时的轻量入场动效 */
.tool:not([hidden]) {
  animation: tool-in 180ms cubic-bezier(0.2, 0.7, 0.3, 1);
}

@keyframes tool-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* 空态里的「插入示例」按钮 */
.empty {
  flex-wrap: wrap;
}

.empty .empty__action {
  flex: none;
  margin-left: auto;
}

/* 输入框右下角的字符 / 行数统计 */
.textarea-meta {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  color: var(--muted-2);
  font-variant-numeric: tabular-nums;
}

/* 拖拽文本文件悬停在输入框上时的提示 */
.textarea.is-dragover {
  box-shadow: 0 0 0 2px var(--accent);
}

/* 代码类输入框的行号槽（wrap=off 保证逻辑行与可视行 1:1） */
.ta-gutter-wrap {
  position: relative;
}

.ta-gutter {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 46px;
  padding: 10px 8px 10px 0;
  overflow: hidden;
  text-align: right;
  background: var(--surface-2);
  box-shadow: var(--shadow-ring);
  border-radius: var(--radius) 0 0 var(--radius);
  color: var(--muted-2);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-sm);
  line-height: 1.6;
  pointer-events: none;
  user-select: none;
}

.ta-gutter span {
  display: block;
}

.textarea.has-gutter {
  padding-left: 60px;
  white-space: pre;
  overflow-x: auto;
}

/* 工具标题区右上角的分享链接按钮 */
.tool__head {
  position: relative;
  padding-right: 40px;
}

.tool__share {
  position: absolute;
  top: 0;
  right: 0;
}

/* 密码 / UUID 生成：逐条列表（一行一条 + 独立复制按钮） */
.pwd-list,
.gen-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pwd-row,
.gen-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  box-shadow: var(--shadow-ring);
}

.gen-row__idx {
  flex: none;
  min-width: 22px;
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-xs);
  color: var(--muted-2);
}

.pwd-row__text,
.gen-row__text {
  min-width: 0;
  overflow-wrap: anywhere;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-md);
  color: var(--fg);
}

.pwd-row__copy {
  flex: none;
  color: var(--muted);
}

/* 搜索命中的关键词高亮（引用类工具） */
mark.hit {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 3px;
  padding: 0 1px;
}

/* HTTP 状态码速查：单容器 + 行分隔（非逐行卡片），状态码按类别着色 */
.http-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow-ring);
  overflow: hidden;
}

.http-list__item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  background: var(--surface);
}

.http-list__item + .http-list__item {
  border-top: 1px solid var(--border);
}

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

.http-list__code {
  flex: none;
  min-width: 36px;
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-md);
  font-weight: 600;
  line-height: 1.45;
}

/* 类别色：1xx 信息灰、2xx 成功绿、3xx 重定向蓝、4xx 客户端橙、5xx 服务端红 */
.http-list__item--c1 .http-list__code { color: var(--muted-2); }
.http-list__item--c2 .http-list__code { color: var(--success); }
.http-list__item--c3 .http-list__code { color: var(--accent); }
.http-list__item--c4 .http-list__code { color: var(--syntax-number); }
.http-list__item--c5 .http-list__code { color: var(--danger); }

.http-list__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.http-list__name {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--fg);
  overflow-wrap: anywhere;
}

.http-list__desc {
  font-size: var(--fs-sm);
  color: var(--muted-2);
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.http-list__copy {
  flex: none;
  color: var(--muted);
}

/* Emoji 速查：字符网格，点击复制 */
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 6px;
}

.emoji-tile {
  display: grid;
  place-items: center;
  min-height: 48px;
  padding: 4px 2px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  box-shadow: var(--shadow-ring);
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  transition: box-shadow 120ms ease, transform 60ms ease;
}

.emoji-tile:hover {
  box-shadow: var(--shadow-ring), 0 0 0 2px var(--accent-soft);
}

.emoji-tile:active {
  transform: translateY(1px);
}

.emoji-tile:focus-visible {
  outline: none;
  box-shadow: var(--shadow-ring), 0 0 0 2px var(--accent);
}

/* 点击复制后的成功反馈：绿色描边一闪 */
.emoji-tile.is-copied {
  box-shadow: var(--shadow-ring), 0 0 0 2px var(--success);
}

/* 命令面板里的“最近使用”标记 */
.palette__item.is-recent .palette__group {
  color: var(--accent);
}

/* 移动端抽屉打开期间锁定背景滚动 */
body.is-drawer-open {
  overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
  .tool:not([hidden]) {
    animation: none;
  }

  .nav-backdrop,
  .sidebar,
  .nav__group-chevron {
    transition: none !important;
  }
}

.tool__head {
  margin-bottom: 20px;
}

.tool__title {
  font-size: var(--fs-2xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.tool__desc {
  margin-top: 6px;
  max-width: 68ch;
  color: var(--muted);
  font-size: var(--fs-sm);
}

/* 页脚说明 */
.app-footer {
  margin-top: 40px;
  padding-top: 16px;
  box-shadow: 0 -1px 0 0 var(--border);
  color: var(--muted-2);
  font-size: var(--fs-xs);
}

/* ========================================================================== 
   组件：卡片 / 面板
   ========================================================================== */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-ring);
  padding: 16px;
}

.card--flush {
  padding: 0;
  overflow: hidden;
}

.card__head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.card__title {
  font-size: var(--fs-md);
  font-weight: 500;
}

/* 输入 / 输出两栏 */
.io-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
}

/* 左右两栏的卡片等高：较短一侧的卡片均摊补足高度，底边对齐 */
.io-col > .card {
  flex: 1 1 auto;
}

.io-grid--single {
  grid-template-columns: minmax(0, 1fr);
}

.io-grid--wide-left {
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
}

/* 侧筛选布局：左窄筛选栏 + 右宽结果列表（HTTP 状态码 / MIME 速查） */
.io-grid--side {
  grid-template-columns: minmax(232px, 300px) minmax(0, 1fr);
}

.io-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.io-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-height: 26px;
}

.io-head__spacer {
  flex: 1 1 auto;
}

.label {
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  font-weight: 500;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.hint {
  color: var(--muted);
  font-size: var(--fs-xs);
  line-height: 1.5;
}

.result-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.result-section__title {
  color: var(--muted-2);
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  font-weight: 500;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

/* Markdown 安全预览 */
.markdown-preview {
  min-height: 240px;
  max-height: 65vh;
  overflow: auto;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--surface-2);
  box-shadow: var(--shadow-ring);
  color: var(--fg);
  overflow-wrap: anywhere;
}

.markdown-preview > * + * {
  margin-top: 12px;
}

.markdown-preview h1,
.markdown-preview h2,
.markdown-preview h3,
.markdown-preview h4 {
  line-height: 1.35;
}

.markdown-preview h1 { font-size: 24px; }
.markdown-preview h2 { font-size: 19px; }
.markdown-preview h3 { font-size: 16px; }

.markdown-preview ul,
.markdown-preview ol {
  padding-left: 24px;
}

.markdown-preview blockquote {
  margin-left: 0;
  padding-left: 12px;
  border-left: 3px solid var(--border);
  color: var(--muted);
}

.markdown-preview code,
.markdown-preview pre {
  font-family: var(--font-mono);
}

.markdown-preview :not(pre) > code {
  padding: 2px 5px;
  border-radius: 4px;
  background: var(--surface);
  box-shadow: var(--shadow-ring);
}

.markdown-preview pre {
  overflow: auto;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-ring);
  white-space: pre;
}

.markdown-preview table {
  width: 100%;
  border-collapse: collapse;
}

.markdown-preview th,
.markdown-preview td {
  padding: 7px 9px;
  border: 1px solid var(--border);
  text-align: left;
}

.markdown-preview a {
  color: var(--accent);
}

.markdown-preview img {
  max-width: 100%;
  height: auto;
}

/* ========================================================================== 
   组件：表单控件
   ========================================================================== */
.input,
.select,
.textarea {
  display: block;
  width: 100%;
  min-width: 0;
  padding: 10px 12px;
  background: var(--surface);
  color: var(--fg);
  border: 0;
  border-radius: var(--radius);
  box-shadow: var(--shadow-ring);
  font-size: var(--fs-md);
  line-height: 1.45;
  transition: box-shadow 120ms ease, background 120ms ease, color 120ms ease;
}

/* 单选控件统一最小高度，保证同一行内输入框与下拉框底边对齐 */
.input,
.select {
  min-height: 38px;
}

/* 下拉展开后的选项：显式指定前景/背景，避免深色主题下与系统默认配色打架 */
.select option,
.select optgroup {
  background: var(--surface);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  padding: 6px 8px;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--muted-2);
}

.input:hover,
.select:hover,
.textarea:hover {
  background: var(--surface-2);
}

.input:focus-visible,
.select:focus-visible,
.textarea:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
  background: var(--surface);
}

.input:disabled,
.select:disabled,
.textarea:disabled {
  color: var(--muted-2);
  background: var(--surface-2);
  cursor: not-allowed;
  opacity: 0.7;
}

.input[aria-invalid="true"],
.textarea[aria-invalid="true"] {
  box-shadow: 0 0 0 1px var(--danger);
}

.input--mono,
.textarea--mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* 触屏设备把输入控件提到 16px，避免 iOS Safari 聚焦时自动缩放页面；
   图标按钮同步放大到 36px，保证可点按目标 */
@media (pointer: coarse) {
  .input,
  .select,
  .textarea {
    font-size: 16px;
  }

  .icon-btn {
    width: 36px;
    height: 36px;
  }
}

.textarea {
  min-height: 168px;
  border-radius: var(--radius);
  resize: vertical;
  line-height: 1.6;
  tab-size: 2;
}

.textarea--short {
  min-height: 96px;
}

.textarea--tall {
  min-height: 240px;
}

/* 只读输出区 */
.output {
  width: 100%;
  min-height: 168px;
  margin: 0;
  padding: 11px;
  background: var(--surface-2);
  border-radius: var(--radius);
  box-shadow: var(--shadow-ring);
  color: var(--fg);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-sm);
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  overflow: auto;
  max-height: 60vh;
}

.output:empty {
  display: none;
}

.output--tall {
  min-height: 240px;
}

/* 结构化文本高亮；同一组颜色覆盖 JSON / YAML / SQL / XML */
.json-key { color: var(--syntax-key); font-weight: 600; }
.json-str { color: var(--syntax-string); }
.json-num { color: var(--syntax-number); }
.json-bool { color: var(--syntax-bool); }
.json-null { color: var(--muted-2); font-style: italic; }
.json-punct { color: var(--muted-2); }

/* 带行号的输出区：行号由 CSS 计数器生成在左侧留白，
   不进入 DOM 文本，因此复制 / 回填的内容不受影响 */
.output--numbered {
  position: relative;
  padding-left: 56px;
  counter-reset: output-line;
}

.output--numbered .ln {
  counter-increment: output-line;
}

.output--numbered .ln::before {
  content: counter(output-line);
  position: absolute;
  left: 0;
  width: 44px;
  padding-right: 12px;
  text-align: right;
  color: var(--muted-2);
  user-select: none;
}

@media (max-width: 600px) {
  .output--numbered { padding-left: 44px; }
  .output--numbered .ln::before { width: 36px; padding-right: 6px; }
}

/* 下拉 */
.select {
  appearance: none;
  padding: 10px 38px 10px 12px;
  cursor: pointer;
  font-weight: 500;
  text-overflow: ellipsis;
}

/* ---------- 自绘下拉（桌面端替换原生弹层，触屏保留系统选择器） ---------- */
.select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 38px;
  padding: 8px 38px 8px 12px;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-ring);
  color: var(--fg);
  font-family: inherit;
  font-size: var(--fs-md);
  font-weight: 500;
  line-height: 1.45;
  text-align: left;
  cursor: pointer;
  transition: box-shadow 120ms ease, background 120ms ease;
}

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

.select-trigger:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
  background: var(--surface);
}

.select-trigger[aria-expanded="true"] {
  background: var(--surface-2);
  box-shadow: var(--shadow-ring), 0 4px 14px -8px rgba(0, 0, 0, 0.35);
}

.select-trigger__label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.select-popup {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 70;
  margin: 0;
  padding: 4px;
  list-style: none;
  max-height: 288px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-ring), 0 14px 36px -14px rgba(0, 0, 0, 0.35);
}

.select-option {
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--fg);
  font-size: var(--fs-md);
  line-height: 1.45;
  cursor: pointer;
  overflow-wrap: anywhere;
}

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

.select-option.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

.select-option[aria-selected="true"] {
  font-weight: 600;
}

.select-option[aria-selected="true"]::after {
  content: '✓';
  float: right;
  color: var(--accent);
}

.select-wrap {
  position: relative;
  min-width: 0;
}

.select-wrap__chevron {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--muted);
  display: grid;
  place-items: center;
  transition: color 120ms ease, transform 120ms ease;
}

.select-wrap:hover .select-wrap__chevron {
  color: var(--fg);
}

.select-wrap:focus-within .select-wrap__chevron {
  color: var(--accent);
}

/* 复选框 / 开关行 */
.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-ring);
  font-size: var(--fs-sm);
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  transition: background 120ms ease, color 120ms ease;
}

.check:hover {
  background: var(--surface-2);
  color: var(--fg);
}

.check input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.check:has(input:checked) {
  color: var(--fg);
}

/* 字段组 */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr));
  gap: 12px;
  align-items: end;
}

/* ==========================================================================
   组件：按钮
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  padding: 6px 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--fg);
  font-size: var(--fs-sm);
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  transition: background 120ms ease, color 120ms ease, opacity 120ms ease,
    transform 60ms ease;
}

/* 主按钮：--fg 实底 + --bg 文字（每屏 accent 使用点 2/2） */
.btn--primary {
  background: var(--fg);
  color: var(--bg);
}

.btn--primary:hover {
  opacity: 0.86;
}

.btn--primary:active {
  opacity: 0.74;
  transform: translateY(1px);
}

/* 次级按钮：透明底 + shadow-ring 描边 */
.btn--ghost {
  background: transparent;
  box-shadow: var(--shadow-ring);
  color: var(--muted);
}

.btn--ghost:hover {
  background: var(--surface-2);
  color: var(--fg);
}

.btn--ghost:active {
  transform: translateY(1px);
}

/* 选中的模式切换按钮（不使用强调色，避免同屏 accent 过多） */
.btn--ghost[aria-pressed="true"] {
  background: var(--surface-2);
  color: var(--fg);
  box-shadow: var(--shadow-ring), inset 0 0 0 1px var(--muted-2);
}

/* 文字按钮：无边框 */
.btn--text {
  padding: 6px 8px;
  color: var(--muted);
  font-weight: 400;
}

.btn--text:hover {
  background: var(--surface-2);
  color: var(--fg);
}

.btn--text:active {
  transform: translateY(1px);
}

.btn--sm {
  min-height: 26px;
  padding: 3px 9px;
  font-size: var(--fs-xs);
}

.btn--danger {
  background: transparent;
  box-shadow: var(--shadow-ring);
  color: var(--danger);
}

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

/* 复制成功反馈 */
.btn.is-done {
  color: var(--success);
}

.btn:disabled,
.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn:disabled:hover {
  background: transparent;
  color: var(--muted);
  opacity: 0.45;
}

.btn__icon {
  display: grid;
  place-items: center;
  flex: none;
}

/* 工具条 */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.toolbar--end {
  justify-content: flex-end;
}

/* ==========================================================================
   组件：状态（空态 / 错误态 / 结果态 / 统计）
   ========================================================================== */
.notice {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.notice__msg {
  min-width: 0;
  flex: 1 1 200px;
}

/* 错误定位片段（含插入符） */
.notice__pre {
  flex: 1 1 100%;
  margin: 2px 0 0;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--fg) 7%, transparent);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  line-height: 1.5;
  white-space: pre;
  overflow-x: auto;
  tab-size: 2;
}

.notice__icon {
  flex: none;
  margin-top: 1px;
  display: grid;
  place-items: center;
}

.notice--error {
  background: color-mix(in srgb, var(--danger) 8%, transparent);
  color: var(--danger);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--danger) 26%, transparent);
}

.notice--ok {
  background: color-mix(in srgb, var(--success) 8%, transparent);
  color: var(--success);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--success) 26%, transparent);
}

.notice--info {
  background: var(--surface-2);
  color: var(--muted);
  box-shadow: var(--shadow-ring);
}

/* 空态 */
.empty {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px;
  border-radius: var(--radius);
  background: var(--surface-2);
  box-shadow: var(--shadow-ring);
  color: var(--muted-2);
  font-size: var(--fs-sm);
  line-height: 1.5;
}

.empty__icon {
  flex: none;
  display: grid;
  place-items: center;
  color: var(--muted-2);
}

/* 统计 */
.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 22px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.stat {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 0;
}

.stat__k {
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.stat__v {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-sm);
  color: var(--fg);
}

/* 键值结果表 */
.kv {
  display: grid;
  grid-template-columns: minmax(88px, auto) minmax(0, 1fr);
  gap: 1px;
  margin: 0;
  background: var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-ring);
}

.kv__k,
.kv__v {
  margin: 0;
  padding: 9px 11px;
  background: var(--surface);
  min-width: 0;
  font-size: var(--fs-sm);
}

/* 长列表斑马纹：dt/dd 成对出现，奇数行铺浅底提升可扫读性 */
.kv > dt:nth-of-type(odd),
.kv > dt:nth-of-type(odd) + dd {
  background: var(--surface-2);
}

/* 悬停整行高亮（:has 不可用时退化为仅值单元格高亮） */
.kv > dd:hover,
.kv > dt:has(+ dd:hover) {
  background: var(--accent-soft);
}

.kv__k {
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted-2);
  display: flex;
  align-items: center;
  gap: 6px;
}

.kv__v {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--fg);
  overflow-wrap: anywhere;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.kv__v > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

/* ==========================================================================
   工具专属
   ========================================================================== */
/* 颜色预览块 */
.swatch {
  width: 100%;
  min-height: 96px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-ring);
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.55);
}

/* 颜色输入行 */
.color-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.color-native {
  width: 40px;
  height: 34px;
  flex: none;
  padding: 2px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-ring);
  cursor: pointer;
}

.color-native::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-native::-webkit-color-swatch {
  border: 0;
  border-radius: 4px;
}

/* 正则高亮结果 */
.match-text {
  margin: 0;
  padding: 11px;
  min-height: 96px;
  border-radius: var(--radius);
  background: var(--surface-2);
  box-shadow: var(--shadow-ring);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 40vh;
  overflow: auto;
}

.match-text mark {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 3px;
  padding: 1px 0;
  box-shadow: inset 0 -2px 0 0 var(--accent);
}

/* 零长度匹配也需可见 */
.match-text mark.mark-empty {
  display: inline-block;
  min-width: 2px;
  height: 1em;
  vertical-align: -0.15em;
  padding: 0;
  box-shadow: none;
  background: var(--accent);
  border-radius: 1px;
}

/* 匹配列表 */
.match-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 46vh;
  overflow: auto;
}

.match-item {
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  box-shadow: var(--shadow-ring);
  padding: 9px 11px;
}

.match-item__head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.match-item__idx {
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.match-item__val {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--fg);
  overflow-wrap: anywhere;
}

.match-item__pos {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  color: var(--muted-2);
  font-variant-numeric: tabular-nums;
}

.match-groups {
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.match-groups li {
  display: flex;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--muted);
  overflow-wrap: anywhere;
}

.match-groups .g-name {
  flex: none;
  color: var(--muted-2);
  letter-spacing: 0.06em;
}

/* 结果段落 */
.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.stack--tight {
  gap: 8px;
}

.inline-note {
  font-size: var(--fs-xs);
  color: var(--muted-2);
}

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   命令面板（原生 dialog）
   ========================================================================== */
.palette {
  width: min(560px, calc(100vw - 32px));
  max-height: min(70vh, 520px);
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--fg);
  box-shadow: 0 0 0 1px var(--border), 0 24px 60px -16px rgba(0, 0, 0, 0.32);
  overflow: hidden;
}

.palette::backdrop {
  background: rgba(0, 0, 0, 0.42);
}

.palette__inner {
  display: flex;
  flex-direction: column;
  max-height: inherit;
}

.palette__search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  box-shadow: 0 1px 0 0 var(--border);
}

.palette__search .input {
  padding: 0;
  min-height: 24px;
  background: transparent;
  box-shadow: none;
  font-size: var(--fs-md);
}

.palette__search .input:focus-visible {
  outline: none;
}

.palette__search .input:hover {
  background: transparent;
}

.palette__list {
  margin: 0;
  padding: 8px;
  list-style: none;
  overflow-y: auto;
  flex: 1 1 auto;
}

.palette__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 11px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-size: var(--fs-sm);
  text-align: left;
  cursor: pointer;
}

.palette__item:hover {
  background: var(--surface-2);
  color: var(--fg);
}

.palette__item.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

.palette__item[aria-current="true"] .palette__name::after {
  content: "当前";
  margin-left: 8px;
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  letter-spacing: 0.06em;
  color: var(--muted-2);
}

.palette__name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.palette__group {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted-2);
  flex: none;
}

.palette__foot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px;
  box-shadow: 0 -1px 0 0 var(--border);
  color: var(--muted-2);
  font-size: var(--fs-xs);
}

.palette__foot .kbd {
  background: var(--surface-2);
}

/* ==========================================================================
   响应式
   ========================================================================== */

/* 平板：768–1023 */
@media (max-width: 1023px) {
  :root {
    --sidebar-w: 196px;
  }

  .app-shell {
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  }

  .app-main {
    padding-left: 24px;
  }

  .io-grid,
  .io-grid--wide-left,
  .io-grid--side {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* 手机：<768 —— 侧栏折叠为抽屉 */
@media (max-width: 767px) {
  .app-shell,
  .app-shell.is-sidebar-collapsed {
    display: block;
    padding: 0 var(--gutter);
  }

  .nav-toggle {
    display: grid;
  }

  .kbd-hint {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    padding: 0;
  }

  .kbd-hint__text,
  .kbd-hint .kbd {
    display: none;
  }

  .brand__sub {
    display: none;
  }

  .sidebar,
  .app-shell.is-sidebar-collapsed .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(280px, 84vw);
    max-height: none;
    padding: 16px 12px;
    overflow-x: visible;
    background: var(--surface);
    box-shadow: 0 0 0 1px var(--border), 24px 0 60px -30px rgba(0, 0, 0, 0.4);
    transform: translateX(-102%);
    transition: transform 180ms ease;
    overflow-y: auto;
    z-index: 60;
    overscroll-behavior: contain;
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .sidebar__actions {
    margin-bottom: 12px;
  }

  .sidebar__collapse {
    display: none;
  }

  .app-shell.is-sidebar-collapsed .nav__group-toggle,
  .app-shell.is-sidebar-collapsed .nav__label {
    display: flex;
  }

  .app-shell.is-sidebar-collapsed .nav__items[hidden] {
    display: none !important;
  }

  .app-shell.is-sidebar-collapsed .nav__link {
    justify-content: flex-start;
    padding: 8px 10px;
  }

  .sidebar__close {
    display: grid;
    margin: 0 0 12px auto;
  }

  .nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(0, 0, 0, 0.42);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
  }

  .nav-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
  }

  .app-main {
    padding: 20px 0 56px;
  }

  .tool__title {
    font-size: 22px;
  }

  .textarea,
  .output,
  .textarea--short,
  .output--tall,
  .textarea--tall {
    min-height: 132px;
    max-height: 50vh;
  }

  .kv {
    grid-template-columns: minmax(0, 1fr);
  }

  .kv__k {
    padding-bottom: 2px;
  }

  .palette {
    width: calc(100vw - 24px);
  }
}

/* 手机竖屏与更窄设备：按钮占满可用宽度 */
@media (max-width: 419px) {
  .toolbar .btn--block-xs {
    flex: 1 1 100%;
  }
}

/* 桌面上隐藏抽屉关闭按钮 */
@media (min-width: 768px) {
  .sidebar__close {
    display: none;
  }
}

/* 减少动效偏好 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* 打印 */
@media print {
  .app-header,
  .sidebar,
  .nav-backdrop,
  .toolbar,
  .palette {
    display: none !important;
  }

  .app-shell {
    display: block;
  }
}

/* 当前时间实时条（日期时间工具顶部常驻） */
.livebar {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 12px 16px;
  margin-bottom: 20px;
  border-radius: var(--radius);
  background: var(--surface-2);
  box-shadow: var(--shadow-ring);
}

.livebar__title {
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.livebar .stats {
  gap: 6px 22px;
}

/* ==========================================================================
   交互优化：模式切换分段控件 / 实时条活动指示 / 可读性细节
   ========================================================================== */

/* 分段控件：把并排的模式按钮收进一条轨道，选中态更明确 */
.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 2px;
  border-radius: var(--radius);
  background: var(--surface-2);
  box-shadow: var(--shadow-ring);
}

.segmented .btn {
  border-radius: calc(var(--radius) - 2px);
}

.segmented .btn--ghost {
  box-shadow: none;
  background: transparent;
  color: var(--muted);
}

.segmented .btn--ghost:hover {
  background: color-mix(in oklch, var(--fg) 7%, transparent);
  color: var(--fg);
}

.segmented .btn--ghost[aria-pressed='true'] {
  background: var(--surface);
  color: var(--fg);
  box-shadow: var(--shadow-ring);
}

/* 实时条：标题与活动指示点 */
.livebar__title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.livebar__dot {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 4px color-mix(in oklch, var(--success) 20%, transparent);
  animation: livePulse 2s ease-in-out infinite;
}

@keyframes livePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

@media (prefers-reduced-motion: reduce) {
  .livebar__dot { animation: none; }
}

/* 结果值：长串可换行、可选中 */
.kv__v {
  overflow-wrap: anywhere;
  user-select: text;
}

/* 导航：键盘焦点可见 */
.nav__link:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* 工具说明：控制单行长度，避免长句铺满 */
.tool__desc {
  max-width: 72ch;
}

.tool__head {
  margin-bottom: 20px;
}

/* ==========================================================================
   第二轮交互优化：实时条一行布局 / 分段控件对比度 / 标签可读性
   ========================================================================== */

/* 实时条：标题与指标一行铺开，复制按钮固定右侧 */
.livebar {
  flex-wrap: nowrap;
}

.livebar .stats {
  flex: 1 1 auto;
  min-width: 0;
}

.livebar .stat {
  flex: none;
}

.livebar > .btn {
  flex: none;
  margin-left: auto;
}

@media (max-width: 860px) {
  .livebar {
    flex-wrap: wrap;
  }

  .livebar .stats {
    flex-basis: 100%;
    order: 3;
  }

  .livebar > .btn {
    margin-left: 0;
  }
}

/* 分段控件：提高轨道与选中态的对比，明确这是单选控件 */
.segmented {
  flex-wrap: wrap;
  width: 100%;
  background: color-mix(in oklch, var(--fg) 5%, var(--surface));
  box-shadow: inset 0 0 0 1px var(--border);
}

.segmented .btn--ghost[aria-pressed='true'] {
  background: var(--surface);
  color: var(--fg);
  box-shadow: 0 0 0 1px var(--border), 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* 结果表标签：提高对比度 */
.kv__k {
  color: var(--muted);
}

/* 模式切换区的间距（作为内容区首行出现） */
.card__head + .stack > .segmented {
  margin-bottom: 4px;
}

/* ==========================================================================
   第三轮：实时条不换行、分段选中态加强、空态可读性
   ========================================================================== */

.livebar__title {
  white-space: nowrap;
}

.livebar .stats {
  gap: 6px 18px;
  row-gap: 6px;
}

/* 分段控件：轨道再加深一档，选中胶囊加边框 */
.segmented {
  background: color-mix(in oklch, var(--fg) 8%, var(--surface));
}

.segmented .btn--ghost[aria-pressed='true'] {
  background: var(--surface);
  color: var(--fg);
  box-shadow: 0 0 0 1px color-mix(in oklch, var(--fg) 22%, transparent), 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* 空态文字对比度 */
.empty {
  color: var(--muted);
}

.empty__icon {
  color: var(--muted-2);
}

@media (min-width: 375px) and (max-width: 767px) {
  .kbd-hint {
    display: inline-flex;
    width: auto;
    padding: 0 8px;
  }

  .kbd-hint__text { display: inline; }
}

/* ==========================================================================
   文本对比：逐行差异视图
   ========================================================================== */
.diff-view {
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-ring);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  line-height: 1.6;
  max-height: 520px;
  overflow-y: auto;
}

.diff-row {
  display: grid;
  grid-template-columns: 18px 48px minmax(0, 1fr);
  gap: 10px;
  padding: 2px 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.diff-row__sign {
  color: var(--muted-2);
  text-align: center;
}

.diff-row__ln {
  color: var(--muted-2);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.diff-row--add {
  background: color-mix(in oklch, var(--success) 12%, transparent);
}

.diff-row--add .diff-row__sign {
  color: var(--success);
}

.diff-row--del {
  background: color-mix(in oklch, var(--danger) 10%, transparent);
}

.diff-row--del .diff-row__sign {
  color: var(--danger);
}

.diff-row--same .diff-row__text {
  color: var(--muted);
}

.diff-row--skip {
  background: var(--surface-2);
  color: var(--muted-2);
  font-size: var(--fs-xs);
}

.textarea--short {
  min-height: 108px;
}

/* ==========================================================================
   二维码生成
   ========================================================================== */
.color-input {
  width: 100%;
  height: 38px;
  padding: 3px;
  border: 0;
  border-radius: var(--radius);
  box-shadow: var(--shadow-ring);
  background: var(--surface);
  cursor: pointer;
}

.qr-frame {
  display: grid;
  place-items: center;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--surface-2);
  box-shadow: var(--shadow-ring);
}

.qr-frame canvas {
  max-width: 100%;
  height: auto;
  image-rendering: pixelated;
  border-radius: var(--radius-sm);
}

/* ==========================================================================
   图片转 Base64
   ========================================================================== */
.img-preview {
  display: grid;
  place-items: center;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--surface-2);
  box-shadow: var(--shadow-ring);
}

.img-preview img {
  max-width: 100%;
  max-height: 320px;
  height: auto;
  border-radius: var(--radius-sm);
}

input[type="file"].input {
  padding: 8px 10px;
  font-size: var(--fs-sm);
  cursor: pointer;
}

input[type="file"].input::file-selector-button {
  margin-right: 10px;
  padding: 5px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  box-shadow: var(--shadow-ring);
  color: var(--fg);
  font: inherit;
  font-size: var(--fs-sm);
  cursor: pointer;
}

/* 侧栏分组层级 */
.nav__section {
  list-style: none;
}

.nav__section + .nav__section {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.nav__group-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  margin: 0 0 4px;
  padding: 6px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-align: left;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
}

.nav__group-toggle:hover {
  background: var(--surface-2);
  color: var(--fg);
}

.nav__group-chevron {
  flex: none;
  transition: transform 140ms ease;
}

.nav__section.is-collapsed .nav__group-chevron {
  transform: rotate(-90deg);
}

/* 首页：全部工具都可见，分组与侧栏共用一份工具注册表。 */
.directory__intro { padding: 28px; border-radius: var(--radius); background: var(--surface-2); box-shadow: var(--shadow-ring); }
.directory__eyebrow { color: var(--muted); font-size: var(--fs-xs); letter-spacing: .04em; }
.directory__intro h2 { margin-top: 8px; font-size: var(--fs-3xl); letter-spacing: -.03em; }
.directory__intro p { margin: 8px 0 20px; color: var(--muted); font-size: var(--fs-sm); }
.directory__search { display: flex; align-items: center; gap: 12px; width: min(100%, 480px); min-height: 48px; padding: 0 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--muted); text-align: left; cursor: pointer; }
.directory__search:hover { border-color: var(--accent); color: var(--fg); }
.directory__search span { flex: 1; }
.directory__search kbd { flex: none; font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--muted-2); }
.directory__jumps { display: flex; flex-wrap: wrap; gap: 8px; margin: 22px 0 4px; }
.directory__jump { min-height: 38px; padding: 7px 12px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--fg); cursor: pointer; font-size: var(--fs-sm); white-space: nowrap; }
.directory__jump:hover { border-color: var(--accent); background: var(--accent-soft); }
.directory__group { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 0 10px; margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--border); }
.directory__group h3 { font-size: var(--fs-lg); font-weight: 600; scroll-margin-top: calc(var(--header-h) + 12px); }
.directory__count { color: var(--muted); font-size: var(--fs-xs); }
.directory__list { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 14px 0 0; padding: 0; list-style: none; }
.directory__link { display: flex; align-items: center; gap: 10px; min-width: 0; min-height: 58px; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius); color: var(--fg); text-decoration: none; font-size: var(--fs-sm); transition: background 120ms ease, border-color 120ms ease; }
.directory__link:hover { border-color: var(--accent); background: var(--accent-soft); }
.directory__link svg { flex: none; color: var(--accent); }
.directory__link span { min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 767px) {
  .directory__intro { padding: 20px; }
  .directory__jumps { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 6px; }
  .directory__jump { min-height: 44px; }
  .directory__list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .directory__link { min-height: 64px; padding: 9px; gap: 8px; }
}
@media (max-width: 359px) { .directory__search kbd { display: none; } }

/* ==========================================================================
   日期时间工具：实时条 / Hero 结果块 / 时区对照
   ========================================================================== */

#panel-timestamp .io-grid { align-items: start; }
.ts-mode-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.ts-mode-group { min-width: 0; }
.ts-mode-group > .label { display: block; margin-bottom: 6px; }
@media (max-width: 767px) { .ts-mode-groups { grid-template-columns: minmax(0, 1fr); } }

.ts-options {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.ts-options > summary {
  min-height: 44px;
  padding: 11px 14px;
  background: var(--surface-2);
  color: var(--fg);
  cursor: pointer;
  font-weight: 500;
}

.ts-options > summary:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.ts-options.is-customized > summary::after { content: ' · 已设置'; color: var(--muted); font-weight: 400; }
.ts-options[open] > summary { border-bottom: 1px solid var(--border); }
.ts-options > .stack { padding: 14px; }

/* 当前时间：读时钟优先，秒数与毫秒数是可复制的次级信息。 */
.ts-live {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 6px 16px;
  padding: 16px 20px;
}
.ts-live .livebar__title { grid-column: 1; grid-row: 1; }
.ts-live__clock {
  grid-column: 1;
  grid-row: 2;
  font-family: var(--font-mono);
  font-size: clamp(1.25rem, 2vw, 1.65rem);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
  white-space: nowrap;
}
.ts-live__pair--sec { grid-column: 2; grid-row: 2; }
.ts-live__pair--ms { grid-column: 3; grid-row: 2; }
.ts-live__pair--utc { grid-column: 1 / -1; grid-row: 3; align-items: baseline; }
#ts-live-pause { grid-column: 2; grid-row: 1; justify-self: end; }
.ts-live__copy { grid-column: 3; grid-row: 1; }
#panel-timestamp .segmented { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
#panel-timestamp .segmented .btn { min-width: 0; white-space: normal; }

@media (max-width: 1000px) {
  .ts-live__clock { grid-column: 1 / -1; }
  .ts-live__pair--sec { grid-column: 1 / 2; grid-row: 3; }
  .ts-live__pair--ms { grid-column: 2 / 4; grid-row: 3; }
  .ts-live__pair--utc { grid-row: 4; }
}
@media (max-width: 600px) {
  .ts-live { gap: 8px 12px; padding: 16px; }
  .ts-live__clock { font-size: clamp(1.2rem, 5.7vw, 1.5rem); white-space: normal; overflow-wrap: anywhere; }
  #panel-timestamp .segmented { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #panel-timestamp .segmented .btn { min-height: 44px; }
}
@media (max-width: 359px) {
  .ts-live__pair--sec { grid-column: 1 / -1; }
  .ts-live__pair--ms { grid-column: 1 / -1; grid-row: 4; }
  .ts-live__pair--utc { grid-row: 5; }
}

.ts-live__pair {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  white-space: nowrap;
}

.ts-live__k {
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.ts-live__v {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
  color: var(--fg);
  cursor: copy;
  padding: 2px 5px;
  border-radius: 4px;
}

.ts-live__v:hover {
  background: color-mix(in oklch, var(--fg) 7%, transparent);
}

.ts-live__v.is-done,
.ts-hero .is-done {
  color: var(--success);
}

.ts-live__v.is-fail,
.ts-hero .is-fail {
  color: var(--danger);
}

/* Hero 结果块：本地时间大字 + 可复制的秒 / 毫秒 + 相对时间徽章 */
.ts-hero {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface-2);
  box-shadow: var(--shadow-ring);
}

.ts-hero__main {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

.ts-hero__label {
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.ts-hero__time {
  font-family: var(--font-mono);
  font-size: var(--fs-2xl);
  font-weight: 600;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
  background: none;
  border: 0;
  padding: 0;
  cursor: copy;
  text-align: left;
  overflow-wrap: anywhere;
}

.ts-hero__time:hover {
  color: var(--accent);
}

.ts-hero__rel {
  font-size: var(--fs-xs);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 8px;
  white-space: nowrap;
}

.ts-hero__rel.is-future {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: transparent;
}

.ts-hero__stamps {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
}

.ts-hero__stamp {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
}

.ts-hero__k {
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.ts-hero__v {
  font-family: var(--font-mono);
  font-size: var(--fs-md);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
  background: none;
  border: 0;
  padding: 2px 4px;
  border-radius: 4px;
  cursor: copy;
}

.ts-hero__v:hover {
  background: color-mix(in oklch, var(--fg) 7%, transparent);
}

/* 明细表降噪：复制按钮常态半隐，悬停 / 聚焦 / 反馈时显现 */
#panel-timestamp .kv .js-copy-value {
  opacity: 0.5;
}

#panel-timestamp .kv .js-copy-value:hover,
#panel-timestamp .kv .js-copy-value:focus-visible,
#panel-timestamp .kv .js-copy-value.is-done {
  opacity: 1;
}

/* 对照表：时区 ID 不做大写变换，标签与芯片同一行 */
#ts-zones-kv .kv__k {
  text-transform: none;
  letter-spacing: 0;
}

.ts-zones-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.chip-group .btn--sm {
  padding: 2px 9px;
  font-size: var(--fs-xs);
}

/* 暂停态：圆点停跳并变灰，标题标注已冻结 */
.livebar.is-paused .livebar__dot {
  animation: none;
  background: var(--muted-2);
  box-shadow: none;
}

.livebar.is-paused .livebar__title {
  color: var(--fg);
}

/* 时区对照勾选芯片：小号按钮，按压态与分段控件一致的胶囊高亮 */
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip-group .btn--ghost {
  box-shadow: var(--shadow-ring);
  background: transparent;
  color: var(--muted);
}

.chip-group .btn--ghost:hover {
  color: var(--fg);
}

.chip-group .btn[aria-pressed='true'] {
  background: var(--surface);
  color: var(--fg);
  box-shadow: 0 0 0 1px color-mix(in oklch, var(--fg) 22%, transparent);
}

/* 日历：不把普通日期画成满屏卡片；选择、今天及法定安排分别识别。 */
.cal-card { max-width: 1080px; padding: 24px; }
.cal-top, .cal-controls, .cal-status-row { display: flex; align-items: center; gap: 8px; }
.cal-top { justify-content: space-between; flex-wrap: wrap; gap: 16px; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.cal-eyebrow { display: block; color: var(--muted); font-size: var(--fs-xs); letter-spacing: 0.03em; }
.cal-heading { margin-top: 3px; font-size: var(--fs-3xl); font-weight: 650; letter-spacing: -0.03em; line-height: 1.25; }
.cal-arrow { width: 42px; height: 42px; padding: 0; font-size: 25px; line-height: 1; }
.cal-jump { position: relative; }
.cal-jump > summary { display: flex; align-items: center; min-height: 42px; padding: 0 12px; border-radius: var(--radius-sm); box-shadow: var(--shadow-ring); cursor: pointer; font-size: var(--fs-sm); list-style: none; }
.cal-jump > summary::-webkit-details-marker { display: none; }
.cal-jump > summary:hover, .cal-jump[open] > summary { background: var(--surface-2); }
.cal-jump > summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.cal-jump .cal-month { position: absolute; z-index: 5; top: calc(100% + 6px); right: 0; width: 170px; background: var(--surface); box-shadow: var(--shadow-ring), 0 8px 20px rgba(0,0,0,.12); }
.cal-body { display: grid; grid-template-columns: minmax(0, 1fr) 230px; gap: 24px; padding-top: 20px; }
.cal-board { min-width: 0; }
.cal-status-row { min-height: 26px; justify-content: space-between; margin-bottom: 16px; }
.cal-status { color: var(--muted); font-size: var(--fs-xs); }
.cal-status::before { content: ''; display: inline-block; width: 7px; height: 7px; margin-right: 8px; border-radius: 50%; background: var(--muted-2); vertical-align: 1px; }
.cal-status[data-state='ready']::before { background: var(--success); }
.cal-status[data-state='error']::before { background: var(--danger); }
.cal-selection { display: none; min-height: 22px; margin-bottom: 10px; font-size: var(--fs-sm); font-weight: 600; }
.cal-weekdays, .cal-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.cal-weekdays { margin-bottom: 4px; color: var(--muted); text-align: center; font-size: var(--fs-xs); }
.cal-weekdays > span { padding: 5px 0; }
.cal-day {
  position: relative; display: flex; flex-direction: column; align-items: flex-start;
  min-width: 0; min-height: 64px; padding: 7px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: transparent; color: var(--fg); text-align: left; cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.cal-day:hover { background: var(--surface-2); border-color: var(--border); }
.cal-day:focus-visible { outline: 2px solid var(--focus); outline-offset: -3px; }
.cal-day[aria-pressed='true'], .cal-day[aria-pressed='true']:hover { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cal-day.is-weekend { color: var(--muted); }
.cal-day.is-off { background: color-mix(in oklch, var(--danger) 9%, var(--surface)); }
.cal-day.is-work { background: color-mix(in oklch, var(--success) 9%, var(--surface)); }
.cal-day.is-off:hover, .cal-day.is-work:hover { filter: brightness(.97); }
.cal-day.is-today .cal-day__num::after { content: ''; display: inline-block; width: 4px; height: 4px; margin: 0 0 3px 4px; border-radius: 50%; background: var(--accent); }
.cal-day__num { font-family: var(--font-mono); font-size: var(--fs-md); font-weight: 600; font-variant-numeric: tabular-nums; }
.cal-day__tag { position: absolute; top: 6px; right: 6px; font-size: var(--fs-xs); font-weight: 700; }
.is-off .cal-day__tag { color: var(--danger); }
.is-work .cal-day__tag { color: var(--success); }
.cal-day__name { max-width: 100%; margin-top: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--fg); font-size: var(--fs-2xs); }
.cal-legend { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 14px; color: var(--muted); font-size: var(--fs-xs); }
.cal-legend__off, .cal-legend__work, .cal-legend__weekend { border-radius: 4px; padding: 1px 5px; }
.cal-legend__off { background: color-mix(in oklch, var(--danger) 9%, var(--surface)); color: var(--danger); }
.cal-legend__work { background: color-mix(in oklch, var(--success) 9%, var(--surface)); color: var(--success); }
.cal-legend__weekend { background: var(--surface-2); color: var(--muted); }
.cal-detail { display: flex; flex-direction: column; align-items: flex-start; align-self: start; min-width: 0; min-height: 240px; padding: 20px; border-radius: var(--radius); background: var(--surface-2); }
.cal-detail strong { display: block; margin-top: 10px; font-family: var(--font-mono); font-size: var(--fs-lg); font-variant-numeric: tabular-nums; line-height: 1.35; }
.cal-detail__kind { margin-top: 12px; padding: 3px 8px; border-radius: 4px; background: var(--surface); color: var(--fg); font-size: var(--fs-xs); font-weight: 600; }
.cal-detail__kind.is-off { color: var(--danger); background: color-mix(in oklch, var(--danger) 10%, var(--surface)); }
.cal-detail__kind.is-work { color: var(--success); background: color-mix(in oklch, var(--success) 10%, var(--surface)); }
.cal-detail p { margin: 14px 0 18px; color: var(--muted); font-size: var(--fs-sm); overflow-wrap: anywhere; }
.cal-use { width: 100%; justify-content: center; margin-top: auto; background: var(--accent); color: var(--bg); }
.cal-use:hover { background: color-mix(in oklch, var(--accent) 84%, black); color: var(--bg); }
.cal-detail__hint { align-self: center; margin-top: 8px; color: var(--muted); font-size: var(--fs-xs); }
#cal-source:not([hidden]) { display: inline-block; margin-top: 16px; font-size: var(--fs-xs); }
.cal-footer { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--border); color: var(--muted); font-size: var(--fs-xs); }

@media (max-width: 1100px) {
  .cal-body { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .cal-detail { min-height: 0; }
  .cal-selection { display: block; }
}
@media (max-width: 600px) {
  .cal-card { padding: 16px 14px; }
  .cal-top { padding-bottom: 16px; }
  .cal-heading { font-size: 24px; }
  .cal-controls { flex-wrap: wrap; width: 100%; }
  .cal-arrow { min-width: 44px; height: 44px; }
  .cal-controls .btn, .cal-jump > summary { min-height: 44px; }
  .cal-status-row { align-items: flex-start; }
  .cal-status { line-height: 1.5; }
  .cal-selection { margin-bottom: 8px; }
  .cal-weekdays, .cal-days { gap: 2px; }
  .cal-day { min-height: 48px; padding: 4px 3px; }
  .cal-day__name { display: none; }
  .cal-day__tag { top: 3px; right: 3px; font-size: 11px; }
  .cal-detail { padding: 16px; }
  .cal-detail p { margin: 8px 0 14px; }
}
@media (max-width: 359px) {
  .cal-day { align-items: center; }
  .cal-day__tag { position: static; line-height: 1; }
}
@media (prefers-reduced-motion: reduce) { .cal-day { transition: none; } }

@media (max-width: 359px) {
  .app-header { gap: 8px; }
}

@media (pointer: coarse) and (max-width: 767px) {
  .app-header .icon-btn,
  .app-header .kbd-hint,
  .sidebar .icon-btn,
  .tool .icon-btn {
    min-width: 44px;
    min-height: 44px;
  }

  .app-header .kbd-hint { width: auto; height: 44px; }
  .app-header .brand { min-height: 44px; }
  .palette__search .input { min-height: 44px; font-size: 16px; }
  .nav__group-toggle, .nav__link, .tool .btn, .tool .select,
  .tool .input, .tool .check, .palette__item { min-height: 44px; }
  #cal-source:not([hidden]) { display: inline-flex; align-items: center; min-height: 44px; }
}

/* ======================================================================
   扩展工具样式：速查表 / 文本清理 / 键盘 / TOTP / 对比度 / JSONPath / HTML 预览等
   ====================================================================== */

.table-wrap {
  overflow-x: auto;
}

.sheet-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

.sheet-table th,
.sheet-table td {
  text-align: left;
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.sheet-table th {
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.sheet-table tbody tr:hover {
  background: var(--surface-2);
}

.sheet-table .ports__desc {
  color: var(--muted);
}

.sheet-table .ports__action {
  text-align: right;
  white-space: nowrap;
}

.sheet-table .ascii__char {
  font-size: var(--fs-lg);
  font-weight: 600;
}

.rmb__out {
  font-size: var(--fs-xl, 18px);
  line-height: 1.6;
}

.keycode__zone {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.keycode__zone:hover {
  border-color: var(--accent);
  color: var(--fg);
}

.keycode__zone:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-color: var(--accent);
  color: var(--fg);
}

.keylog {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 320px;
  overflow-y: auto;
}

.keylog__row {
  display: flex;
  gap: 12px;
  align-items: baseline;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}

.keylog__key {
  font-weight: 600;
  min-width: 88px;
}

.keylog__detail {
  color: var(--muted-2);
  font-size: var(--fs-xs);
}

.totp__code {
  font-size: 34px;
  letter-spacing: 0.12em;
  text-align: center;
  margin: 8px 0;
  font-variant-numeric: tabular-nums;
}

.totp__meter {
  height: 6px;
  border-radius: 3px;
  background: var(--surface-2);
  box-shadow: var(--shadow-ring);
  overflow: hidden;
}

.totp__bar {
  height: 100%;
  width: 100%;
  background: var(--accent);
  transition: width 0.4s linear;
}

.contrast__ratio {
  font-size: var(--fs-2xl);
  margin: 4px 0 12px;
}

.contrast__preview {
  border-radius: var(--radius);
  box-shadow: var(--shadow-ring);
  padding: 18px 16px;
  margin-bottom: 12px;
  display: grid;
  gap: 10px;
}

.contrast__sample {
  margin: 0;
}

.contrast__sample--large {
  font-size: 24px;
}

.contrast__level {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: var(--fs-xs);
  box-shadow: var(--shadow-ring);
}

.contrast__level.is-pass {
  color: var(--success);
}

.contrast__level.is-fail {
  color: var(--danger);
}

.contrast__picker {
  padding: 2px;
  height: 38px;
  width: 56px;
  cursor: pointer;
}

.jsonpath__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px;
}

.jsonpath__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: var(--fs-sm);
}

.jsonpath__value {
  max-height: 200px;
  overflow: auto;
}

.htmlprev__frame {
  width: 100%;
  height: 420px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #ffffff;
}
