/* =========================================================
 * 图片工具箱 —— 全站样式（浅色主题 / 卡片式 / 无外部依赖）
 * ========================================================= */

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-soft: #94a3b8;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --bg: #f5f7fb;
  --card: #ffffff;
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --info-bg: #eff6ff;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px rgba(15, 23, 42, .06);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

h1, h2, h3, p, ul, li, figure { margin: 0; padding: 0; }
ul { list-style: none; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.hidden { display: none !important; }

/* ---------- 顶部导航 ---------- */
.topbar {
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: .2px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.brand:hover { text-decoration: none; }
.brand::before {
  content: "";
  width: 18px;
  height: 18px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--primary), #60a5fa);
  display: inline-block;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav-name {
  color: var(--text-muted);
  font-size: 14px;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- 布局 ---------- */
.container {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 20px 40px;
  flex: 1 0 auto;
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 6px;
}

.page-subtitle {
  color: var(--text-muted);
  margin-bottom: 22px;
  font-size: 15px;
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 18px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.card-head h2 {
  font-size: 17px;
  font-weight: 700;
}

.card-head .card-tip {
  font-size: 13px;
  color: var(--text-soft);
}

/* ---------- 按钮 ---------- */
.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  padding: 9px 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, opacity .15s ease;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:disabled, .btn[disabled] { opacity: .55; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }

.btn-ghost { background: #fff; border-color: var(--border-strong); color: var(--text); }
.btn-ghost:hover:not(:disabled) { background: #f8fafc; border-color: var(--text-soft); }

.btn-danger { color: var(--danger); border-color: #fecaca; }
.btn-danger:hover:not(:disabled) { background: var(--danger-bg); border-color: #fca5a5; }
.btn-danger.is-armed { background: var(--danger); color: #fff; border-color: var(--danger); }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 13px 24px; font-size: 16px; border-radius: var(--radius); }
.btn-block { display: flex; width: 100%; }

/* 处理中的转圈 */
.spinner {
  display: none;
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, .45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.btn.is-loading .spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 上传区 ---------- */
.drop-zone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  background: #fbfcfe;
  padding: 38px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease, transform .15s ease;
}
.drop-zone:hover { border-color: var(--primary); background: var(--primary-light); }
.drop-zone:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.drop-zone.is-drag {
  border-color: var(--primary);
  background: var(--primary-light);
  transform: scale(1.005);
}

.drop-icon {
  font-size: 30px;
  line-height: 1;
  margin-bottom: 10px;
}

.drop-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
}

.drop-hint {
  font-size: 13px;
  color: var(--text-soft);
}

/* 原图预览 */
.preview-box {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fbfcfe;
}

.preview-thumb {
  width: 88px;
  height: 88px;
  flex: 0 0 88px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #fff;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.preview-thumb img { max-width: 100%; max-height: 100%; display: block; object-fit: contain; }

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

.preview-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-size { color: var(--text-muted); font-size: 13px; margin-bottom: 8px; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }

.field-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}

.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.field-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary);
  min-width: 34px;
  text-align: right;
}

.field-hint {
  font-size: 13px;
  color: var(--text-soft);
  margin-top: 6px;
}

input[type="text"], input[type="password"], input[type="email"], input[type="number"], select {
  width: 100%;
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input[type="text"]:focus, input[type="password"]:focus, input[type="email"]:focus,
input[type="number"]:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}
input::placeholder { color: var(--text-soft); }

input[type="range"] {
  width: 100%;
  appearance: none;
  height: 6px;
  border-radius: 999px;
  background: #e5eaf3;
  outline: none;
  margin: 6px 0;
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(15, 23, 42, .3);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary);
  border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(15, 23, 42, .3);
  cursor: pointer;
}
input[type="range"]:disabled { opacity: .5; cursor: not-allowed; }
input[type="range"]:disabled::-webkit-slider-thumb { background: var(--text-soft); cursor: not-allowed; }

.is-disabled { opacity: .55; }
.is-disabled .field-label, .is-disabled .field-value { color: var(--text-soft); }

/* 单选组 */
.radio-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.radio {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  background: #fff;
  transition: border-color .15s ease, background-color .15s ease, color .15s ease;
}
.radio:hover { border-color: var(--primary); }
.radio input { accent-color: var(--primary); margin: 0; }
.radio:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 600;
}

/* 尺寸输入 */
.size-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.size-x { color: var(--text-soft); flex: 0 0 auto; }

/* 水印 */
.wm-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.wm-row select { width: auto; min-width: 132px; flex: 0 0 auto; }
.wm-opacity {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 220px;
  min-width: 200px;
}
.wm-opacity span { font-size: 13px; color: var(--text-muted); white-space: nowrap; }
.wm-opacity #wm-opacity-value { color: var(--primary); font-weight: 700; }

/* ---------- 操作按钮条 ---------- */
.actions { margin-bottom: 18px; }

/* ---------- 结果区 ---------- */
.result-summary {
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 18px;
  border: 1px solid var(--border);
  background: #f8fafc;
}
.result-summary.is-good { background: var(--success-bg); border-color: #bbf7d0; }
.result-summary.is-neutral { background: var(--warn-bg); border-color: #fde68a; }

.result-title { font-size: 16px; font-weight: 700; }
.result-summary.is-good .result-title { color: #15803d; }
.result-summary.is-neutral .result-title { color: var(--warn); }

.result-flow { color: var(--text-muted); font-size: 14px; margin-top: 4px; }
.result-flow strong { color: var(--text); }

.result-grid {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.result-preview {
  flex: 1 1 280px;
  min-width: 240px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: repeating-conic-gradient(#f1f5f9 0% 25%, #ffffff 0% 50%) 50% / 18px 18px;
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: 380px;
  overflow: hidden;
}
.result-preview img {
  max-width: 100%;
  max-height: 340px;
  display: block;
  border-radius: 6px;
  object-fit: contain;
}

.result-info { flex: 1 1 240px; min-width: 220px; }

.info-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 14px;
}
.info-row:last-of-type { border-bottom: none; }
.info-label { color: var(--text-muted); flex: 0 0 auto; }
.info-value { font-weight: 600; text-align: right; word-break: break-all; }

.result-info .btn { margin-top: 16px; }

/* ---------- 处理记录 ---------- */
.record {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.record:last-child { border-bottom: none; padding-bottom: 0; }
.record:first-child { padding-top: 0; }

.record-main { min-width: 0; flex: 1 1 auto; }
.record-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.record-meta { font-size: 13px; color: var(--text-muted); }
.record-time { font-size: 12px; color: var(--text-soft); }

.record-actions { display: flex; gap: 8px; flex: 0 0 auto; }

.empty-hint {
  text-align: center;
  color: var(--text-soft);
  font-size: 14px;
  padding: 18px 0;
}

/* ---------- 登录页 ---------- */
.auth-wrap {
  max-width: 440px;
  margin: 32px auto;
  padding: 0 20px;
  width: 100%;
}

.auth-card { padding: 26px; }

.auth-head { text-align: center; margin-bottom: 20px; }
.auth-head h1 { font-size: 21px; font-weight: 700; }
.auth-head p { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: #f1f5f9;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
}
.tab {
  flex: 1 1 0;
  appearance: none;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 9px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] {
  background: #fff;
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.form-msg {
  display: none;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.form-msg.is-visible { display: block; }
.form-msg.is-error { background: var(--danger-bg); border-color: #fecaca; color: var(--danger); }
.form-msg.is-success { background: var(--success-bg); border-color: #bbf7d0; color: #15803d; }
.form-msg.is-info { background: var(--info-bg); border-color: #bfdbfe; color: var(--primary-dark); }

.auth-foot {
  text-align: center;
  font-size: 13px;
  color: var(--text-soft);
  margin-top: 16px;
}

/* ---------- 页脚 ---------- */
.footer {
  flex: 0 0 auto;
  border-top: 1px solid var(--border);
  background: #fff;
  padding: 18px 20px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}
.footer p + p { margin-top: 4px; color: var(--text-soft); font-size: 12px; }

/* ---------- Toast 提示 ---------- */
.toast-wrap {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(92vw, 460px);
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(15, 23, 42, .14);
  padding: 11px 14px;
  font-size: 14px;
  animation: toast-in .18s ease-out;
}
.toast-error { border-left-color: var(--danger); }
.toast-success { border-left-color: var(--success); }
.toast-warn { border-left-color: var(--warn); }

.toast-msg { flex: 1 1 auto; }
.toast-action {
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  background: none;
  border: none;
  font-family: inherit;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}
.toast-close {
  flex: 0 0 auto;
  border: none;
  background: none;
  color: var(--text-soft);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}
.toast-close:hover { color: var(--text); }

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

/* ---------- 手机适配（768px 断点） ---------- */
@media (max-width: 768px) {
  body { font-size: 14.5px; }

  .topbar-inner { padding: 10px 14px; }
  .container { padding: 18px 14px 30px; }

  .card { padding: 16px; border-radius: var(--radius); }
  .page-title { font-size: 20px; }
  .card-head h2 { font-size: 16px; }

  .drop-zone { padding: 28px 14px; }

  .preview-box { flex-direction: column; align-items: flex-start; }
  .preview-thumb { width: 100%; height: 160px; flex: 0 0 auto; }

  .radio-group { gap: 8px; }
  .radio { flex: 1 1 44%; justify-content: center; padding: 9px 10px; }

  .wm-row { flex-direction: column; align-items: stretch; }
  .wm-row select { width: 100%; }
  .wm-opacity { min-width: 0; flex: 1 1 auto; }

  .result-preview { max-height: 260px; }
  .result-preview img { max-height: 230px; }

  .record { flex-direction: column; align-items: stretch; gap: 10px; }
  .record-actions { justify-content: flex-start; }
  .record-actions .btn { flex: 1 1 auto; }

  .btn-lg { width: 100%; }

  .toast-wrap { top: 12px; width: 94vw; }
}
