/* =========================================================================
   devbox 主样式
   组织方式：
     1. 设计令牌（设计变量）
     2. 深色模式
     3. 基础重置与排版
     4. 布局：侧边栏 / 内容区 / 移动端
     5. 组件：按钮、表单、卡片、表格、提示、徽章
     6. 登录页
     7. 工具局部样式（.httptest-* / .passgen-*）
   不使用 CSS 嵌套，兼容较老的 Android WebView。
   ========================================================================= */

/* ---------- 1. 设计令牌 ---------- */
:root {
  color-scheme: light;

  --bg: #f7f8fa;
  --bg-elevated: #ffffff;
  --bg-subtle: #f0f2f5;
  --bg-hover: #e9edf2;

  --fg: #1b1f24;
  --fg-muted: #626b76;
  --fg-faint: #8b949e;

  --border: #d9dee5;
  --border-strong: #c3cad3;

  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #e6efff;

  --success: #15803d;
  --success-soft: #e8f7ee;
  --danger: #c62828;
  --danger-hover: #a91f1f;
  --on-danger: #ffffff;
  --danger-soft: #fdeaea;
  --warning: #a15c00;
  --warning-soft: #fdf3e2;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 6px 20px rgba(16, 24, 40, 0.08);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;

  /* 表单与交互组件统一尺寸，避免不同浏览器/元素类型产生高度差。 */
  --control-height: 42px;
  --control-padding-x: 12px;
  --btn-height: 42px;
  --btn-height-sm: 32px;
  --toast-width: 360px;
  --modal-width: 440px;
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%23626b76' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;

  --sidebar-width: 232px;
  --sidebar-width-collapsed: 68px;
  --content-max: 1080px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo,
    "Courier New", monospace;
}

/* ---------- 2. 深色模式 ---------- */
/* 手动指定优先；未指定时跟随系统。 */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0d1117;
  --bg-elevated: #161b22;
  --bg-subtle: #1c2128;
  --bg-hover: #222831;

  --fg: #e6edf3;
  --fg-muted: #9ba7b4;
  --fg-faint: #6e7681;

  --border: #2d333b;
  --border-strong: #3d444d;

  --accent: #4b8bf5;
  --accent-hover: #6ba1f7;
  --accent-soft: #1a2b47;

  --success: #4ac26b;
  --success-soft: #14261a;
  --danger: #f17c7c;
  --danger-hover: #f59a9a;
  --on-danger: #161b22;
  --danger-soft: #2c1717;
  --warning: #e3b341;
  --warning-soft: #2a2113;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%239ba7b4' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --bg: #0d1117;
    --bg-elevated: #161b22;
    --bg-subtle: #1c2128;
    --bg-hover: #222831;

    --fg: #e6edf3;
    --fg-muted: #9ba7b4;
    --fg-faint: #6e7681;

    --border: #2d333b;
    --border-strong: #3d444d;

    --accent: #4b8bf5;
    --accent-hover: #6ba1f7;
    --accent-soft: #1a2b47;

    --success: #4ac26b;
    --success-soft: #14261a;
    --danger: #f17c7c;
    --danger-hover: #f59a9a;
    --on-danger: #161b22;
    --danger-soft: #2c1717;
    --warning: #e3b341;
    --warning-soft: #2a2113;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
    --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%239ba7b4' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  }
}

/* ---------- 3. 基础 ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
}

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

body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.modal-open {
  overflow: hidden;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.3;
  font-weight: 650;
}

h1 {
  font-size: 1.5rem;
}

h2 {
  font-size: 1rem;
  letter-spacing: 0.01em;
}

h3 {
  margin: 0 0 var(--space-2);
  font-size: 0.95rem;
  font-weight: 650;
}

p {
  margin: 0 0 var(--space-3);
}

p:last-child {
  margin-bottom: 0;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code,
pre {
  font-family: var(--font-mono);
  font-size: 0.875em;
}

code {
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
}

pre {
  overflow: auto;
  padding: var(--space-4);
  border-radius: var(--radius);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
}

pre code {
  padding: 0;
  border: 0;
  background: none;
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: var(--space-4) 0;
}

::selection {
  background: var(--accent-soft);
}

/* ---------- 4. 布局 ---------- */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
  transition: grid-template-columns 0.16s ease;
}

/* 收起侧边栏：只保留图标列。 */
:root.is-nav-collapsed .app-shell {
  grid-template-columns: var(--sidebar-width-collapsed) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-4);
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
  padding: 0 var(--space-2);
  color: inherit;
  text-decoration: none;
}

.brand:hover {
  text-decoration: none;
  opacity: 0.9;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand-mark-lg {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  font-size: 17px;
}

.brand-name {
  font-weight: 650;
  letter-spacing: 0.02em;
}

/* LOGO 行：品牌与菜单收起按钮。 */
.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.sidebar-toggle {
  flex: none;
  width: 30px;
  height: 30px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
  overflow-y: auto;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--fg-muted);
  font-size: 0.94rem;
}

.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
}

.nav-icon svg {
  display: block;
  width: 18px;
  height: 18px;
}

.nav-label {
  min-width: 0;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--fg);
  text-decoration: none;
}

.nav-item.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

/* 工具分组：一级菜单 + 可折叠的二级菜单 */
.nav-group {
  margin: 0;
}

.nav-group > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  list-style: none;
  cursor: pointer;
}

.nav-group > summary .nav-label {
  flex: 1 1 auto;
}

.nav-group > summary::-webkit-details-marker {
  display: none;
}

.nav-group > summary::after {
  content: "›";
  font-size: 1.05em;
  transform: rotate(90deg);
  transition: transform 0.15s ease;
}

.nav-group[open] > summary::after {
  transform: rotate(-90deg);
}

.nav-sub {
  padding-left: 38px;
  font-size: 0.9rem;
}

/* 二级菜单之间保留间距，避免选中/未选中的背景块贴在一起。 */
.nav-group > summary + .nav-sub,
.nav-sub + .nav-sub {
  margin-top: 4px;
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  overflow: hidden;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
}

.avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-xs {
  width: 28px;
  height: 28px;
  font-size: 0.75rem;
}

.avatar-lg {
  width: 72px;
  height: 72px;
  font-size: 1.5rem;
}

.avatar-initial {
  transform: translateY(1px);
}

/* 头像即上传入口：悬停提示“更换头像”，点击后选择图片。 */
.avatar-upload {
  position: relative;
  cursor: pointer;
}

.avatar-upload .avatar-file {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.avatar-upload .avatar-upload-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.02em;
  text-align: center;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}

.avatar-upload:hover .avatar-upload-hint,
.avatar-upload:focus-within .avatar-upload-hint {
  opacity: 1;
}

.avatar-upload:focus-within {
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.mobile-avatar:hover {
  text-decoration: none;
  opacity: 0.9;
}

.sidebar-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2);
  border-top: 1px solid var(--border);
}

.sidebar-foot form {
  margin: 0;
}

.sidebar-menu {
  position: relative;
}

.sidebar-popover {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 184px;
  padding: 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}

.sidebar-popover[hidden] {
  display: none;
}

.sidebar-popover .nav-item {
  font-size: 0.9rem;
  padding: 8px 10px;
}

/* ---------- 侧边栏收起态 ---------- */
:root.is-nav-collapsed .sidebar {
  padding: var(--space-4) var(--space-2);
  gap: var(--space-3);
}

:root.is-nav-collapsed .sidebar-head {
  flex-direction: column;
  gap: var(--space-2);
}

:root.is-nav-collapsed .brand {
  justify-content: center;
  padding: 0;
}

:root.is-nav-collapsed .brand-name {
  display: none;
}

:root.is-nav-collapsed .nav > .nav-item,
:root.is-nav-collapsed .nav-group > summary {
  justify-content: center;
  padding: 10px 0;
}

/* 视觉上隐藏文字，但仍保留给读屏器。 */
:root.is-nav-collapsed .nav .nav-label {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

:root.is-nav-collapsed .nav-sub {
  display: none;
}

:root.is-nav-collapsed .nav-group > summary::after {
  display: none;
}

:root.is-nav-collapsed .sidebar-foot {
  flex-direction: column;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) 0;
}

/* 收起时管理菜单向右弹出，避免超出窄侧栏。 */
:root.is-nav-collapsed .sidebar-popover {
  left: calc(100% + 10px);
  top: auto;
  bottom: 0;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--fg-muted);
  cursor: pointer;
}

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

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

.avatar-icon {
  overflow: hidden;
  padding: 0;
  border-radius: 50%;
  background: var(--bg);
  text-decoration: none;
}

.avatar-icon:hover {
  background: var(--bg-hover);
  text-decoration: none;
}

.avatar-icon img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-icon .avatar-initial {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: var(--fg-muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.content {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-6) var(--space-5) var(--space-6);
}

/* 两栏列表页：占满可用宽度，扩大右侧查看面积 */
.content-wide {
  max-width: none;
  padding: var(--space-5) var(--space-5) var(--space-5);
}

.content-wide .notes-layout,
.content-wide .notes-detail {
  min-height: calc(100vh - 120px);
  min-height: calc(100dvh - 120px);
}

.content-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.content-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.mobile-bar,
.bottom-nav {
  display: none;
}

.mobile-actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.mobile-actions form {
  margin: 0;
}

.more-list {
  display: flex;
  flex-direction: column;
}

.more-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
  color: var(--fg);
}

.more-item:last-child {
  border-bottom: 0;
}

.more-item:hover {
  color: var(--accent);
  text-decoration: none;
}

/* ---------- 5. 组件 ---------- */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.card-head h2 {
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fg-muted);
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.stat {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-4);
  margin-bottom: 0;
}

.stat-link {
  color: inherit;
  text-decoration: none;
}

.stat-link:hover {
  text-decoration: none;
  border-color: var(--accent);
  box-shadow: var(--shadow-md);
}

.stat-label {
  color: var(--fg-muted);
  font-size: 0.82rem;
}

.stat-value {
  font-size: 1.7rem;
  font-weight: 650;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

/* 键值列表 */
.kv {
  display: grid;
  grid-template-columns: minmax(120px, max-content) minmax(0, 1fr);
  gap: var(--space-2) var(--space-5);
  margin: 0 0 var(--space-3);
}

.kv dt {
  color: var(--fg-muted);
  font-size: 0.9rem;
}

.kv dd {
  margin: 0;
  word-break: break-word;
}

/* 按钮：显式高度 + flex 居中，保证 <a>、<button> 在不同浏览器中一致。 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: var(--btn-height);
  min-height: var(--btn-height);
  padding: 0 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--fg);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 550;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.btn:hover {
  background: var(--bg-hover);
  text-decoration: none;
}

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

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}

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

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

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--on-danger);
}

.btn-danger:hover {
  color: var(--on-danger);
  background: var(--danger-hover);
  border-color: var(--danger-hover);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--fg-muted);
}

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

/* 次要操作：保留可见边框，与主要按钮区分 */
.btn-outline {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--fg-muted);
}

.btn-outline:hover {
  background: var(--bg-hover);
  color: var(--fg);
}

.btn-outline-danger {
  background: transparent;
  color: var(--danger);
}

.btn-outline-danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.btn-sm {
  height: var(--btn-height-sm);
  min-height: var(--btn-height-sm);
  padding: 0 11px;
  font-size: 0.85rem;
}

.btn-block {
  width: 100%;
}

/* 表单 */
.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}

.field-label {
  font-size: 0.88rem;
  font-weight: 550;
  line-height: 1.4;
  color: var(--fg-muted);
}

.field-hint {
  margin: 0;
  color: var(--fg-faint);
  font-size: 0.82rem;
  line-height: 1.5;
}

.input,
select,
textarea {
  width: 100%;
  padding: 9px var(--control-padding-x);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background-color: var(--bg-elevated);
  color: var(--fg);
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

/* input 与 select 统一固定高度，避免各平台原生控件高度不一致。 */
.input,
select,
select.input {
  height: var(--control-height);
  min-height: var(--control-height);
  padding-top: 0;
  padding-bottom: 0;
}

textarea,
textarea.input {
  height: auto;
  min-height: 110px;
  padding: 9px var(--control-padding-x);
  line-height: 1.6;
  resize: vertical;
}

/* 下拉框：使用自绘箭头，右侧留出足够空间，避免箭头贴边。 */
select,
select.input {
  padding-left: var(--control-padding-x);
  padding-right: 38px;
  background-image: var(--select-arrow);
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px 12px;
}

select[multiple],
select[size] {
  height: auto;
  min-height: var(--control-height);
  padding-right: var(--control-padding-x);
  background-image: none;
}

select::-ms-expand {
  display: none;
}

.input::placeholder,
textarea::placeholder {
  color: var(--fg-faint);
  opacity: 1;
}

.input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input:disabled,
select:disabled,
textarea:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background-color: var(--bg-subtle);
}

.input[aria-invalid="true"],
.input.is-invalid,
select[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="month"] {
  padding-right: 10px;
  -webkit-appearance: auto;
  appearance: auto;
}

input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator,
input[type="month"]::-webkit-calendar-picker-indicator {
  opacity: 0.65;
  cursor: pointer;
}

.checkbox input,
.checkbox-row input {
  width: 17px;
  height: 17px;
  margin: 0;
  flex: none;
  accent-color: var(--accent);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* 表单里的独立按钮默认按内容宽度，避免被 flex 拉伸成整行。 */
.stack > .btn {
  align-self: flex-start;
}

.inline {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0;
}

/* 分类输入：已有分类下拉；选择“新建分类”时再显示文本框。 */
.category-picker {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* 提示 */
.alert {
  padding: 10px 14px;
  margin-bottom: var(--space-4);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 0.92rem;
}

.alert-success {
  background: var(--success-soft);
  border-color: var(--success);
  color: var(--success);
}

.alert-danger {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger);
}

.alert-warning {
  background: var(--warning-soft);
  border-color: var(--warning);
  color: var(--warning);
}

/* 徽章 */
.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--fg-muted);
  font-size: 0.78rem;
  font-weight: 550;
}

.badge-ok {
  background: var(--success-soft);
  border-color: var(--success);
  color: var(--success);
}

.badge-danger {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger);
}

/* Toast：固定定位，不占用文档流，出现/消失不会推动页面内容。 */
.toast-region {
  position: fixed;
  right: var(--space-4);
  bottom: var(--space-4);
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: min(var(--toast-width), calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: 11px 12px 11px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-left: 4px solid var(--success);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  color: var(--fg);
  font-size: 0.92rem;
  line-height: 1.55;
  pointer-events: auto;
  animation: toast-in 0.18s ease-out;
}

.toast-success {
  border-left-color: var(--success);
}

.toast-error {
  border-left-color: var(--danger);
}

.toast-warning {
  border-left-color: var(--warning);
}

.toast-message {
  flex: 1;
  min-width: 0;
  word-break: break-word;
  white-space: pre-wrap;
}

.toast-close {
  flex: none;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--fg-faint);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.toast-close:hover {
  background: var(--bg-hover);
  color: var(--fg);
}

.toast.is-leaving {
  animation: toast-out 0.18s ease-in forwards;
}

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

@keyframes toast-out {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* 统一弹框：不依赖 <dialog>，兼容老 Android WebView。 */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  background: rgba(15, 23, 42, 0.52);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.16s ease, visibility 0.16s ease;
}

.modal-backdrop.is-open {
  opacity: 1;
  visibility: visible;
}

.modal {
  width: 100%;
  max-width: var(--modal-width);
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
  padding: var(--space-5);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(8px) scale(0.98);
  transition: opacity 0.16s ease, transform 0.16s ease;
}

.modal-backdrop.is-open .modal {
  opacity: 1;
  transform: none;
}

.modal-title {
  margin: 0 0 var(--space-2);
  font-size: 1.05rem;
  font-weight: 650;
  line-height: 1.35;
}

.modal-message {
  margin: 0;
  overflow: auto;
  color: var(--fg-muted);
  font-size: 0.94rem;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.modal-field {
  margin-top: var(--space-3);
}

.modal-error {
  display: none;
  margin-top: var(--space-2);
  color: var(--danger);
  font-size: 0.86rem;
}

.modal-error.is-visible {
  display: block;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-5);
}

.modal-actions .btn {
  min-width: 84px;
}

/* 表格（工具页面通用） */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

.table-wrap .table {
  min-width: 560px;
}

.table-wrap .table.login-table {
  min-width: 520px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

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

.table th {
  color: var(--fg-muted);
  font-weight: 550;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.table tr:hover td {
  background: var(--bg-subtle);
}

/* 辅助类 */
.muted {
  color: var(--fg-muted);
}

.small {
  font-size: 0.86rem;
}

.mobile-only {
  display: none;
}

.break {
  word-break: break-all;
}

.selectable {
  user-select: all;
}

.mt-2 {
  margin-top: var(--space-2);
}

.mt-4 {
  margin-top: var(--space-4);
}

/* ---------- 6. 登录页 ---------- */
.auth-shell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: var(--space-5);
  background:
    radial-gradient(1200px 600px at 10% -10%, var(--accent-soft), transparent 60%),
    var(--bg);
}

.auth-main {
  width: 100%;
  max-width: 400px;
}

.auth-card {
  padding: var(--space-6) var(--space-5) var(--space-5);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.auth-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
  text-align: center;
}

.auth-head h1 {
  font-size: 1.35rem;
  letter-spacing: 0.04em;
}

.auth-hint {
  margin-top: var(--space-4);
  font-size: 0.82rem;
  text-align: center;
}

/* ---------- 6.0 用户资料 ---------- */
.profile-head {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: 0;
}

.profile-avatar-tip {
  margin-top: calc(var(--space-2) * -1);
}

.profile-head-main {
  min-width: 0;
}

.profile-head-main h2 {
  margin-bottom: 2px;
  font-size: 1.2rem;
}

.profile-head-main p {
  margin-bottom: 4px;
}

.profile-avatar-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

.profile-avatar-remove {
  margin: 0;
}

.login-ua {
  margin-top: 2px;
  font-size: 0.78rem;
  line-height: 1.4;
  word-break: break-all;
}

input[type="file"].input {
  height: auto;
  min-height: var(--control-height);
  padding: 8px 10px;
  line-height: 1.4;
}

/* ---------- 6.1 笔记与凭证 ---------- */
.note-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: 6px;
}

.tag {
  display: inline-block;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.78rem;
  text-decoration: none;
}

.tag:hover {
  text-decoration: none;
  filter: brightness(1.1);
}

.empty-state {
  padding: var(--space-6);
  text-align: center;
  color: var(--fg-muted);
}

.fieldset {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin: 0;
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.fieldset legend {
  padding: 0 var(--space-2);
  color: var(--fg-muted);
  font-size: 0.86rem;
  font-weight: 600;
}

.textarea-lg {
  min-height: 300px;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.7;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.form-actions .btn {
  flex: 0 0 auto;
}

/* 分类管理等页面使用 */
.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  max-width: 540px;
}

.inline-form .input {
  flex: 1 1 220px;
  min-width: 0;
}

.input-compact {
  height: var(--btn-height-sm);
  min-height: var(--btn-height-sm);
  max-width: 240px;
  padding: 0 9px;
  font-size: 0.9rem;
}

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

.table .inline {
  margin: 0;
}

.checkbox-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.92rem;
  line-height: 1.4;
  cursor: pointer;
}

details summary {
  color: var(--fg-muted);
  font-size: 0.9rem;
  cursor: pointer;
}

details[open] summary {
  margin-bottom: var(--space-2);
}

.secret-grid {
  display: grid;
  grid-template-columns: minmax(90px, max-content) minmax(0, 1fr);
  gap: var(--space-2) var(--space-4);
  margin: 0;
}

.secret-grid dt {
  padding-top: 4px;
  color: var(--fg-muted);
  font-size: 0.86rem;
}

.secret-grid dd {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0;
}

.secret-value {
  font-family: var(--font-mono);
  word-break: break-all;
}

.secret-value.is-masked {
  filter: blur(5px);
  cursor: pointer;
  transition: filter 0.15s ease;
}

.secret-value.is-masked:hover,
.secret-value.is-revealed {
  filter: none;
}

/* Markdown 渲染 */
.markdown-body {
  line-height: 1.75;
  word-wrap: break-word;
}

.markdown-body > :first-child {
  margin-top: 0;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  margin: 1.4em 0 0.6em;
  line-height: 1.35;
}

.markdown-body h1 {
  font-size: 1.4rem;
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--border);
}

.markdown-body h2 {
  font-size: 1.15rem;
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--border);
}

.markdown-body h3 {
  font-size: 1.02rem;
}

.markdown-body ul,
.markdown-body ol {
  padding-left: 1.5em;
  margin: 0.6em 0;
}

.markdown-body li + li {
  margin-top: 0.25em;
}

/* GFM 任务列表：去掉项目符号，复选框与文字对齐。 */
.markdown-body li:has(> input[type="checkbox"]) {
  list-style: none;
  margin-left: -1.2em;
}

.markdown-body li > input[type="checkbox"] {
  margin: 0 0.45em 0 0;
  vertical-align: middle;
}

.markdown-body blockquote {
  margin: 0.8em 0;
  padding: 0.2em 0 0.2em 1em;
  border-left: 3px solid var(--accent);
  color: var(--fg-muted);
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
  font-size: 0.92rem;
}

.markdown-body th,
.markdown-body td {
  padding: 7px 10px;
  border: 1px solid var(--border);
}

.markdown-body th {
  background: var(--bg-subtle);
  font-weight: 600;
}

.markdown-body img {
  max-width: 100%;
  border-radius: var(--radius-sm);
}

.markdown-body pre {
  margin: 1em 0;
  border-radius: var(--radius);
  /* 代码块固定深色，避免 highlight.js 主题在浅色页面下对比度过低 */
  background: #0d1117;
  border: 1px solid #30363d;
  color: #c9d1d9;
}

.markdown-body pre code {
  display: block;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  line-height: 1.6;
}

.markdown-body :not(pre) > code {
  font-size: 0.86em;
}

.markdown-body hr {
  margin: 1.6em 0;
}

/* ---------- 6.2 两栏笔记 ---------- */
.notes-layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: var(--space-4);
  align-items: start;
}

.notes-listpane {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 0;
  padding: var(--space-3);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.notes-filter {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.notes-filter-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.notes-filter-row .input {
  flex: 1;
  min-width: 0;
}

.notes-count {
  margin-left: auto;
}

.notes-empty {
  padding: var(--space-3);
}

.notes-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px solid var(--border);
}

.note-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: calc(100vh - 240px);
  max-height: calc(100dvh - 240px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.note-list-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--fg);
}

.note-list-item:hover {
  background: var(--bg-hover);
  text-decoration: none;
}

.note-list-item.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.note-list-title {
  font-size: 0.94rem;
  font-weight: 600;
  word-break: break-word;
}

.note-list-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

/* 列表页左侧面板：每条记录为独立色块，块间留白，不使用边框。 */
.notes-listpane .note-list {
  gap: var(--space-2);
}

.notes-listpane .note-list-item {
  padding: 12px 14px;
  background: var(--bg-subtle);
  border: 0;
  border-radius: var(--radius-sm);
  transition: background-color 0.12s ease;
}

.notes-listpane .note-list-item:hover {
  background: var(--bg-hover);
}

.notes-listpane .note-list-item.is-active {
  background: var(--accent-soft);
}

.notes-detail {
  margin-bottom: 0;
  min-height: 320px;
  transition: opacity 0.12s ease;
}

.notes-detail.is-loading {
  opacity: 0.55;
}

.note-meta-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2) var(--space-3);
  margin: var(--space-2) 0 var(--space-3);
  padding: 8px 12px;
  background: var(--bg-subtle);
  border: 0;
  border-radius: var(--radius-sm);
}

.note-times {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-4);
  min-width: 0;
}

.note-time {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}

.note-time-label {
  color: var(--fg-muted);
  font-size: 0.78rem;
}

.note-time-value {
  color: var(--fg-muted);
  font-size: 0.82rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.note-pane-actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin-left: auto;
}

.note-pane-title {
  margin-bottom: var(--space-2);
  font-size: 1.3rem;
}

.note-pane-body {
  margin-top: var(--space-4);
}

.notes-back {
  display: none;
}

.badge-warn {
  background: var(--warning-soft);
  border-color: var(--warning);
  color: var(--warning);
}

.todo-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-3) 0;
  padding: var(--space-3);
  background: var(--bg-subtle);
  border-radius: var(--radius);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}

.done-checkbox {
  align-self: end;
  padding: 9px 0;
}

/* ---------- 6.3 Markdown 编辑器 ---------- */
.md-editor {
  overflow: hidden;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}

.md-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: 6px 8px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
}

.md-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  align-items: center;
}

.md-sep {
  width: 1px;
  height: 18px;
  margin: 0 4px;
  background: var(--border);
}

.md-btn-danger {
  color: var(--danger);
}

.md-btn-danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.md-btn:disabled {
  opacity: 0.5;
  cursor: wait;
}

.md-btn {
  min-width: 30px;
  height: 28px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--fg-muted);
  font-size: 0.85rem;
  cursor: pointer;
}

.md-btn:hover {
  background: var(--bg-hover);
  color: var(--fg);
}

.md-tabs {
  display: flex;
  gap: 2px;
}

.md-tab {
  padding: 4px 10px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--fg-muted);
  font-size: 0.82rem;
  cursor: pointer;
}

.md-tab.is-active {
  background: var(--bg-elevated);
  border-color: var(--border);
  color: var(--fg);
}

.md-textarea {
  min-height: 340px;
  border: 0;
  border-radius: 0;
}

.md-textarea:focus {
  box-shadow: none;
}

.md-preview {
  min-height: 340px;
  padding: var(--space-4);
}

/* ---------- 7. 工具局部样式 ---------- */
/* HTTP 测试：Thunder Client 风格的工作台 */
.method-GET {
  color: var(--success);
}

.method-POST {
  color: var(--warning);
}

.method-PUT {
  color: var(--accent);
}

.method-PATCH {
  color: var(--accent);
}

.method-DELETE {
  color: var(--danger);
}

.method-HEAD,
.method-OPTIONS {
  color: var(--fg-muted);
}

.httptest-method {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  min-width: 42px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.httptest-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--bg-subtle);
  color: var(--fg-muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  flex: none;
}

.httptest-status.is-ok {
  background: var(--success-soft);
  color: var(--success);
}

.httptest-status.is-redirect {
  background: var(--warning-soft);
  color: var(--warning);
}

.httptest-status.is-error {
  background: var(--danger-soft);
  color: var(--danger);
}

/* PC 上让工作台占满内容区高度，左右/上下区域各自滚动。 */
@media (min-width: 769px) {
  .page-plugin_httptest_workspace {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    padding-top: var(--space-4);
    padding-bottom: var(--space-4);
  }

  .page-plugin_httptest_workspace .content-head {
    flex: none;
    margin-bottom: var(--space-3);
  }

  .page-plugin_httptest_workspace .httptest-workspace {
    flex: 1;
    min-height: 0;
  }
}

.httptest-workspace {
  --httptest-control-height: var(--btn-height-sm);

  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  gap: var(--space-4);
  min-height: 0;
}

/* HTTP 测试工作台内的表单控件与“保存模板”按钮保持同一高度。 */
.httptest-workspace .input:not(textarea),
.httptest-workspace select,
.httptest-workspace .btn,
.httptest-workspace .httptest-add-row {
  height: var(--httptest-control-height);
  min-height: var(--httptest-control-height);
}

.httptest-side {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.httptest-side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  flex: none;
  padding: 10px var(--space-3);
  border-bottom: 1px solid var(--border);
}

.httptest-side-title {
  color: var(--fg-muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.httptest-side-head a {
  font-size: 0.78rem;
}

.httptest-new {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--fg-muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.httptest-link-btn {
  padding: 2px 4px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--fg-muted);
  font: inherit;
  font-size: 0.75rem;
  cursor: pointer;
}

.httptest-link-btn:hover {
  background: var(--bg-hover);
  color: var(--fg);
}

.httptest-new:hover {
  background: var(--bg-hover);
  color: var(--fg);
  text-decoration: none;
}

.httptest-side-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 6px;
}

.httptest-template-list,
.httptest-history-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.httptest-template {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: 7px 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--fg);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.httptest-template:hover {
  background: var(--bg-hover);
  text-decoration: none;
}

.httptest-template.is-active {
  background: var(--accent-soft);
}

.httptest-template-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.httptest-template-name {
  overflow: hidden;
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.httptest-template-url {
  overflow: hidden;
  color: var(--fg-faint);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  line-height: 1.5;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.httptest-side-split {
  margin-top: var(--space-3);
  padding-top: var(--space-2);
  border-top: 1px solid var(--border);
}

.httptest-side-split .httptest-side-head {
  padding-top: var(--space-2);
  padding-bottom: var(--space-2);
  border-bottom: 0;
}

.httptest-history {
  display: grid;
  grid-template-columns: 38px 38px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 6px 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--fg-muted);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.httptest-history:hover {
  background: var(--bg-hover);
  text-decoration: none;
}

.httptest-history.is-active {
  background: var(--bg-subtle);
}

.httptest-history-url {
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.httptest-side-empty {
  margin: 0;
  padding: var(--space-2) 8px var(--space-3);
  color: var(--fg-faint);
  font-size: 0.78rem;
  line-height: 1.5;
}

.httptest-main {
  display: grid;
  grid-template-rows: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: var(--space-4);
  min-height: 0;
}

.httptest-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.httptest-topbar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: none;
  padding: var(--space-3);
  border-bottom: 1px solid var(--border);
}

.httptest-method-select {
  flex: 0 0 104px;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 700;
}

.httptest-url {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

.httptest-send {
  flex: none;
  min-width: 72px;
}

.httptest-proxy-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  color: var(--fg-muted);
  font-size: 0.8rem;
  cursor: pointer;
  user-select: none;
}

.httptest-proxy-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.httptest-switch {
  position: relative;
  width: 32px;
  height: 18px;
  border-radius: 999px;
  background: var(--border-strong);
  transition: background 0.15s ease;
}

.httptest-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s ease;
}

.httptest-proxy-toggle input:checked + .httptest-switch {
  background: var(--accent);
}

.httptest-proxy-toggle input:checked + .httptest-switch::after {
  transform: translateX(14px);
}

.httptest-proxy-toggle input:focus-visible + .httptest-switch {
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.httptest-pane-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  flex: none;
}

.httptest-inline-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--fg-muted);
  font-size: 0.8rem;
}

.httptest-inline-field .input {
  width: auto;
  min-width: 150px;
  height: var(--httptest-control-height);
  min-height: var(--httptest-control-height);
  padding-top: 0;
  padding-bottom: 0;
  font-size: 0.84rem;
}

.httptest-btn-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.httptest-btn-group .btn.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.httptest-kv-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
  padding: 4px;
  margin: -4px;
  overflow: auto;
}

.httptest-kv-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) minmax(0, 1.2fr) 30px;
  align-items: center;
  gap: 6px;
}

.httptest-kv-row.is-form {
  grid-template-columns: 22px 92px minmax(0, 1fr) minmax(0, 1.3fr) 30px;
}

.httptest-kv-row.is-disabled .httptest-kv-key,
.httptest-kv-row.is-disabled .httptest-kv-value,
.httptest-kv-row.is-disabled .httptest-kv-type {
  opacity: 0.5;
}

.httptest-kv-row input[type="checkbox"] {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--accent);
}

.httptest-kv-row .input {
  height: var(--httptest-control-height);
  min-height: var(--httptest-control-height);
  padding-top: 0;
  padding-bottom: 0;
  font-size: 0.82rem;
}

.httptest-kv-key {
  font-family: var(--font-mono);
}

.httptest-kv-row select.input {
  padding-left: 8px;
  padding-right: 24px;
  background-position: right 7px center;
}

.httptest-kv-file {
  min-width: 0;
  height: var(--httptest-control-height);
  min-height: var(--httptest-control-height);
  padding: 4px 6px;
  font-size: 0.74rem;
}

.httptest-kv-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: var(--httptest-control-height);
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--fg-faint);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.httptest-kv-remove:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.httptest-add-row {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  padding: 0 10px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--fg-muted);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}

.httptest-add-row:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.httptest-auth,
.httptest-settings {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  max-width: 560px;
}

.httptest-auth-pane,
.httptest-body-pane {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-height: 0;
}

.httptest-auth-pane[hidden],
.httptest-body-pane[hidden] {
  display: none;
}

.httptest-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}

.httptest-check {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  align-self: end;
  min-height: var(--httptest-control-height);
  color: var(--fg-muted);
  font-size: 0.86rem;
}

.httptest-check input {
  accent-color: var(--accent);
}

.httptest-body-pane {
  flex: 1;
}

.httptest-body-pane .httptest-textarea {
  flex: 1;
}

.httptest-request-editor {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.httptest-tabbar {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: none;
  min-height: 38px;
  padding: 0 var(--space-2);
  border-bottom: 1px solid var(--border);
}

.httptest-tab {
  appearance: none;
  padding: 8px 12px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--fg-muted);
  font: inherit;
  font-size: 0.84rem;
  cursor: pointer;
}

.httptest-tab:hover {
  color: var(--fg);
}

.httptest-tab.is-active {
  border-bottom-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.httptest-tabpanes {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.httptest-tabpane {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--space-2);
  min-height: 0;
  overflow: auto;
  padding: var(--space-3);
}

.httptest-tabpane[hidden] {
  display: none;
}

.httptest-pane-hint {
  flex: none;
  margin: 0;
  color: var(--fg-faint);
  font-size: 0.76rem;
}

.httptest-textarea {
  flex: 1;
  min-height: 120px;
  resize: none;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  line-height: 1.55;
}

.httptest-response-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex: none;
  padding: 10px var(--space-3);
  border-bottom: 1px solid var(--border);
}

.httptest-response-meta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.httptest-meta-item {
  color: var(--fg-muted);
  font-family: var(--font-mono);
  font-size: 0.76rem;
}

.httptest-response {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.httptest-response-result {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.httptest-response-result[hidden] {
  display: none;
}

.httptest-result-pane {
  gap: 0;
  padding: 0;
  overflow: hidden;
}

.httptest-final-url {
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.httptest-header-list,
.httptest-cookie-list,
.httptest-redirect-list {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  overflow: auto;
  padding: 6px var(--space-3) var(--space-3);
  font-size: 0.82rem;
}

.httptest-header-row {
  display: grid;
  grid-template-columns: minmax(140px, 220px) minmax(0, 1fr);
  gap: var(--space-3);
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
  word-break: break-all;
}

.httptest-header-row code {
  padding: 0;
  border: 0;
  background: none;
  color: var(--fg);
  font-weight: 600;
}

.httptest-header-row span {
  color: var(--fg-muted);
  font-family: var(--font-mono);
}

.httptest-cookie-row,
.httptest-redirect-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
}

.httptest-cookie-row:last-child,
.httptest-redirect-row:last-child,
.httptest-header-row:last-child {
  border-bottom: 0;
}

.httptest-cookie-main,
.httptest-redirect-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.httptest-cookie-meta,
.httptest-redirect-meta {
  color: var(--fg-faint);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  word-break: break-all;
}

.httptest-list-empty {
  padding: var(--space-3) 0;
  color: var(--fg-faint);
  font-size: 0.82rem;
}

.httptest-pane-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  flex: none;
  padding: 2px var(--space-3);
  border-bottom: 1px solid var(--border);
}

.httptest-pre {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: var(--space-3);
  overflow: auto;
  border: 0;
  border-radius: 0;
  background: var(--bg-subtle);
  font-size: 0.82rem;
}

.httptest-empty {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: var(--space-5);
  text-align: center;
  color: var(--fg-muted);
}

.httptest-empty p {
  margin: 0;
}

.httptest-empty-icon {
  margin-bottom: var(--space-1);
  color: var(--fg-faint);
  font-size: 1.6rem;
  line-height: 1;
}

/* 密码生成器 */
.passgen-output {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.passgen-output .input {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  letter-spacing: 0.04em;
}

/* ---------- 响应式 ---------- */
@media (max-width: 1180px) {
  .httptest-workspace {
    grid-template-columns: 210px minmax(0, 1fr);
  }
}

@media (max-width: 980px) {
  .page-plugin_httptest_workspace {
    height: auto;
  }

  .httptest-workspace {
    grid-template-columns: 1fr;
  }

  .httptest-side {
    max-height: 320px;
  }

  .httptest-main {
    grid-template-rows: minmax(360px, 1fr) minmax(320px, 0.8fr);
  }
}

@media (max-width: 900px) {
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    display: none;
  }

  .mobile-bar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px var(--space-4);
    background: var(--bg-elevated);
    background: color-mix(in srgb, var(--bg-elevated) 88%, transparent);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
  }

  .content {
    padding: var(--space-4) var(--space-4) 96px;
  }

  .content-head {
    align-items: flex-start;
    flex-wrap: wrap;
    margin-bottom: var(--space-4);
  }

  .content-actions {
    flex-wrap: wrap;
  }

  .bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    display: flex;
    justify-content: space-around;
    padding: 6px var(--space-2) calc(6px + env(safe-area-inset-bottom));
    background: var(--bg-elevated);
    border-top: 1px solid var(--border);
  }

  .bottom-item {
    flex: 1;
    padding: 8px 0;
    text-align: center;
    color: var(--fg-muted);
    font-size: 0.82rem;
  }

  .bottom-item.is-active {
    color: var(--accent);
    font-weight: 600;
  }

  .kv {
    grid-template-columns: 1fr;
    gap: 2px var(--space-3);
  }

  .kv dt {
    margin-top: var(--space-2);
    font-size: 0.8rem;
  }

  .card {
    padding: var(--space-4);
  }

  .auth-shell {
    align-items: flex-start;
    padding: var(--space-4);
  }

  .auth-main {
    margin-top: 8vh;
  }

  .profile-head {
    align-items: flex-start;
  }

  .profile-head .avatar-lg {
    width: 56px;
    height: 56px;
    font-size: 1.2rem;
  }

  .profile-avatar-actions {
    justify-content: flex-start;
  }

  .profile-avatar-remove {
    flex: 1 1 auto;
  }

  .profile-avatar-remove .btn {
    width: 100%;
  }

  .httptest-topbar {
    flex-wrap: wrap;
  }

  .httptest-method-select {
    flex: 0 0 92px;
  }

  .httptest-url {
    flex: 1 1 180px;
  }

  .httptest-send {
    flex: 1 1 90px;
  }

  .httptest-proxy-toggle {
    margin-left: auto;
  }

  .httptest-kv-row.is-form {
    grid-template-columns: 20px 70px minmax(0, 1fr) minmax(0, 1fr) 26px;
    gap: 4px;
  }

  .httptest-grid-2 {
    grid-template-columns: 1fr;
  }

  .httptest-side {
    max-height: 240px;
  }

  .httptest-main {
    grid-template-rows: minmax(340px, auto) minmax(300px, auto);
  }

  .notes-layout {
    grid-template-columns: 1fr;
  }

  .notes-listpane {
    padding: var(--space-2);
  }

  .notes-listpane .note-list-item {
    padding: 13px 12px;
  }

  .notes-layout.has-selection .notes-listpane {
    display: none;
  }

  /* 手机端未选中记录时不显示空详情卡片，避免列表下方出现大块空白。 */
  .notes-layout:not(.has-selection) .notes-detail {
    display: none;
  }

  /* 列表页默认选中第一条只用于桌面端预览，手机端未点选前保持普通色块。 */
  .notes-layout:not(.has-selection) .note-list-item.is-active:not(:hover) {
    background: var(--bg-subtle);
  }

  .notes-back {
    display: inline-flex;
    align-self: flex-start;
    height: auto;
    min-height: 36px;
    margin-bottom: 6px;
    padding: 6px 12px;
    border: 0;
    border-radius: 999px;
    background: var(--bg-subtle);
    color: var(--fg-muted);
    font-size: 0.85rem;
  }

  .notes-back:hover,
  .notes-back:active {
    background: var(--bg-hover);
    color: var(--fg);
  }

  .note-list {
    max-height: none;
  }

  .notes-filter-row {
    flex-wrap: wrap;
  }

  .notes-filter-row .input {
    flex: 1 1 160px;
  }

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

  /* 详情元信息在移动端分两段：创建/更新时间各占一行，操作按钮另起一行。 */
  .note-meta-bar {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-3);
    padding: 10px 12px;
  }

  .note-times {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    width: 100%;
  }

  .note-time {
    flex-direction: row;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-3);
    width: 100%;
  }

  .note-time-value {
    text-align: right;
  }

  .note-meta-bar .note-pane-actions {
    justify-content: stretch;
    gap: var(--space-2);
    width: 100%;
    margin-left: 0;
  }

  .note-meta-bar .note-pane-actions > * {
    flex: 1 1 0;
    min-width: 0;
  }

  .note-meta-bar .note-pane-actions .btn {
    width: 100%;
  }

  .mobile-only {
    display: block;
  }

  /* 16px 可避免 iOS Safari 聚焦输入框时自动放大页面。 */
  .input,
  select,
  textarea {
    font-size: 16px;
  }

  .form-actions {
    flex-direction: column-reverse;
  }

  .form-actions .btn {
    width: 100%;
  }

  .stack > .btn {
    align-self: stretch;
  }

  .inline-form {
    max-width: none;
  }

  .inline-form .input {
    flex: 1 1 100%;
  }

  .inline-form .btn {
    width: 100%;
  }

  /* 手机端只保留纯文本编辑，隐藏 Markdown 工具栏和预览。 */
  .md-toolbar,
  .md-preview {
    display: none !important;
  }

  /* 若用户先在桌面端切到预览再缩到手机宽度，仍保证正文可编辑。 */
  .md-textarea[hidden] {
    display: block !important;
  }

  .md-textarea {
    min-height: 48vh;
    padding: 12px;
    font-size: 16px;
  }

  .table-wrap .table {
    min-width: 640px;
  }

  .toast-region {
    top: auto;
    bottom: calc(68px + env(safe-area-inset-bottom));
    left: var(--space-4);
    right: var(--space-4);
    width: auto;
  }

  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }

  .modal {
    max-width: none;
    max-height: 88vh;
    max-height: 88dvh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  }

  .modal-actions {
    flex-direction: column;
  }

  .modal-actions .btn {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
