:root {
  color-scheme: light;
  --ink: #17223a;
  --ink-soft: #31405d;
  --paper: #f4f7fb;
  --surface: #ffffff;
  --blue: #3158d7;
  --blue-dark: #2445af;
  --coral: #eb675b;
  --mint: #92cbb4;
  --line: #d7deea;
  --line-strong: #b7c2d3;
  --muted: #68758d;
  --danger: #c73939;
  --shadow: 0 18px 55px rgba(29, 44, 74, 0.12);
  --radius: 10px;
  font-family: "Microsoft YaHei UI", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--paper); }
body { margin: 0; color: var(--ink); background: var(--paper); }
button, input { font: inherit; }
button, a, label[for] { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 3px solid rgba(49, 88, 215, 0.35);
  outline-offset: 3px;
}

.muted { color: var(--muted); }
.form-error { margin: 0; color: var(--danger); font-size: 13px; line-height: 1.5; }

.brand-mark {
  display: grid;
  grid-template-columns: repeat(2, 22px);
  gap: 5px;
  width: max-content;
}
.brand-mark span {
  width: 22px;
  height: 15px;
  border: 2px solid var(--ink);
  border-radius: 3px;
}
.brand-mark span:first-child,
.brand-mark span:last-child { background: var(--coral); border-color: var(--coral); }
.brand-mark.small { grid-template-columns: repeat(2, 13px); gap: 3px; }
.brand-mark.small span { width: 13px; height: 9px; border-width: 1px; border-radius: 2px; }

.brand-row { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-row strong { display: block; font-size: 17px; letter-spacing: 0.04em; }
.brand-row small { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }

.button {
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 7px;
  font-weight: 700;
  color: var(--ink);
  background: transparent;
  transition: transform 120ms ease, background-color 120ms ease, border-color 120ms ease;
}
.button:hover { transform: translateY(-1px); }
.button:active { transform: translateY(0); }
.button:disabled { cursor: wait; opacity: 0.58; transform: none; }
.button.primary { color: white; background: var(--blue); }
.button.primary:hover { background: var(--blue-dark); }
.button.dark { color: white; background: var(--ink); }
.button.coral { color: white; background: var(--coral); }
.button.outline { border-color: var(--line-strong); background: white; }
.button.ghost { min-height: 36px; padding: 0 12px; border-color: var(--line); background: white; }
.button.wide { width: 100%; }

input[type="text"], input[type="password"], input[type="url"], input[inputmode="numeric"] {
  width: 100%;
  height: 46px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 0 13px;
  color: var(--ink);
  background: white;
}
input::placeholder { color: #9aa5b7; }
input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(49, 88, 215, 0.1); outline: none; }

.login-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  background:
    linear-gradient(90deg, transparent 49.8%, rgba(49, 88, 215, 0.08) 50%, transparent 50.2%),
    linear-gradient(rgba(23, 34, 58, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 34, 58, 0.035) 1px, transparent 1px),
    var(--paper);
  background-size: auto, 30px 30px, 30px 30px, auto;
}
.login-card {
  width: min(440px, 100%);
  padding: 46px;
  border: 1px solid var(--line);
  border-top: 5px solid var(--blue);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.product-name { margin: 22px 0 7px; color: var(--blue); font-size: 14px; font-weight: 800; letter-spacing: 0.08em; }
.login-card h1 { margin: 0; font-family: Bahnschrift, "Microsoft YaHei UI", sans-serif; font-size: clamp(30px, 6vw, 44px); letter-spacing: -0.03em; }
.login-card > .muted { margin: 12px 0 28px; line-height: 1.7; }
.stack-form { display: grid; gap: 14px; }
.stack-form label:not(.mobile-picker) { font-size: 13px; font-weight: 700; }

.mobile-shell {
  min-height: 100dvh;
  padding: 20px;
  display: grid;
  place-items: center;
  background: var(--ink);
}
.mobile-card { width: min(520px, 100%); padding: 28px; border-radius: 14px; background: var(--surface); }
.mobile-kicker { margin: 34px 0 7px; color: var(--blue); font-size: 13px; font-weight: 800; }
.mobile-card h1 { margin: 0; font-size: clamp(26px, 7vw, 38px); }
.mobile-card > .muted { line-height: 1.6; }
.mobile-picker {
  min-height: 190px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 24px;
  border: 2px dashed var(--line-strong);
  border-radius: 10px;
  background: var(--paper);
  text-align: center;
  cursor: pointer;
}
.mobile-picker > span:last-child { color: var(--muted); font-size: 13px; }
.mobile-file-row { display: flex; align-items: center; gap: 12px; min-height: 42px; }
.mobile-file-row .file-summary { flex: 1; min-width: 0; }
.mobile-file-row .button { flex: 0 0 auto; min-height: 36px; padding: 0 12px; }
.picker-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; color: white; background: var(--blue); font-size: 28px; }
.mobile-success { padding: 30px 0 8px; text-align: center; }
.mobile-success > span { display: grid; place-items: center; width: 58px; height: 58px; margin: auto; border-radius: 50%; color: var(--ink); background: var(--mint); font-size: 30px; font-weight: 900; }
.mobile-success h2 { margin-bottom: 6px; }
.mobile-success p { margin-top: 0; color: var(--muted); line-height: 1.6; }

.app-shell { min-height: 100dvh; }
.topbar {
  height: 72px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}
.topbar-actions { display: flex; align-items: center; gap: 18px; }
.status-dot { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.status-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 0 4px rgba(146, 203, 180, 0.2); }

.workspace { min-height: calc(100dvh - 72px); display: grid; grid-template-columns: 368px minmax(0, 1fr); }
.control-panel { border-right: 1px solid var(--line); background: var(--surface); }
.panel-section { padding: 28px; border-bottom: 1px solid var(--line); }
.panel-section > label, .upload-section form > label:not(.drop-zone) { display: block; margin-bottom: 9px; font-size: 13px; font-weight: 800; }
.search-section { background: #edf1fb; }
.search-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.search-row input { min-width: 0; }
.section-heading h2 { margin: 0; font-family: Bahnschrift, "Microsoft YaHei UI", sans-serif; font-size: 24px; }
.section-heading p { margin: 6px 0 24px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.drop-zone {
  min-height: 150px;
  margin: 16px 0 10px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  border: 2px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink-soft);
  background: var(--paper);
  cursor: pointer;
}
.drop-zone.dragging { border-color: var(--blue); background: #edf1ff; }
.drop-zone > span:last-child { color: var(--muted); font-size: 12px; }
.drop-glyph { color: var(--coral); font-size: 30px; line-height: 1; }
.file-summary { min-height: 21px; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.split-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
.dingtalk-section { background: #fff8f5; }
.dingtalk-section .section-heading p.configured { color: #237755; font-weight: 700; }

.gallery-panel { min-width: 0; padding: 34px 38px 60px; }
.gallery-header { min-height: 105px; display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--line); }
.gallery-label { margin: 0 0 6px; color: var(--coral); font-size: 12px; font-weight: 800; }
.gallery-header h1 { margin: 0; font-family: Bahnschrift, "Microsoft YaHei UI", sans-serif; font-size: clamp(28px, 4vw, 44px); letter-spacing: -0.025em; }
.gallery-header .muted { margin: 8px 0 24px; font-size: 13px; }
.selection-actions { display: flex; align-items: center; gap: 12px; padding-top: 12px; }
.selection-actions span { color: var(--muted); font-size: 13px; }

.empty-state { min-height: 460px; display: grid; place-items: center; align-content: center; text-align: center; }
.empty-state h2 { margin: 25px 0 6px; font-size: 20px; }
.empty-state p { margin: 0; color: var(--muted); font-size: 13px; }
.empty-contact-sheet { width: min(340px, 72vw); display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; transform: rotate(-2deg); }
.empty-contact-sheet span { aspect-ratio: 4 / 3; border: 1px solid var(--line-strong); background: repeating-linear-gradient(135deg, transparent 0 10px, rgba(49, 88, 215, 0.06) 10px 11px); }
.loading-state { min-height: 420px; display: grid; place-items: center; align-content: center; gap: 14px; color: var(--muted); }
.loading-state span { width: 30px; height: 30px; border: 3px solid var(--line); border-top-color: var(--blue); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.gallery-grid { padding-top: 24px; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }
.image-card { position: relative; min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.image-card.selected { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(49, 88, 215, 0.16); }
.image-check { position: absolute; z-index: 2; top: 12px; left: 12px; width: 24px; height: 24px; accent-color: var(--blue); }
.image-frame { aspect-ratio: 4 / 3; display: grid; place-items: center; overflow: hidden; background: #dce3ef; text-decoration: none; }
.image-frame:focus-visible { outline: 3px solid var(--blue); outline-offset: -3px; }
.image-frame img { width: 100%; height: 100%; object-fit: cover; }
.image-info { padding: 14px; }
.image-index { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-family: Bahnschrift, sans-serif; font-size: 11px; }
.image-actions { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; margin-top: 13px; }
.image-actions a, .image-actions button { min-height: 36px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); background: white; font-size: 12px; font-weight: 700; text-decoration: none; }
.image-actions button { width: 42px; color: var(--danger); }

.qr-dialog { width: min(430px, calc(100% - 32px)); padding: 34px; border: 0; border-radius: 12px; color: var(--ink); box-shadow: var(--shadow); text-align: center; }
.qr-dialog::backdrop { background: rgba(23, 34, 58, 0.66); backdrop-filter: blur(3px); }
.dialog-close { position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; border: 0; border-radius: 50%; color: var(--ink); background: var(--paper); font-size: 25px; }
.qr-dialog .mobile-kicker { margin-top: 4px; }
.qr-dialog h2 { margin: 8px 0; }
.qr-dialog img { width: min(300px, 100%); margin: 16px auto; border: 8px solid var(--paper); border-radius: 8px; }
.qr-loading { margin: 28px 0; color: var(--muted); }
.copy-link { display: block; color: var(--blue); font-size: 13px; font-weight: 700; }
.settings-dialog { text-align: left; }
.settings-dialog .muted { line-height: 1.6; }
.settings-note { margin: -2px 0 2px; color: var(--muted); font-size: 12px; line-height: 1.6; }

.toast { position: fixed; z-index: 10; right: 24px; bottom: 24px; max-width: min(390px, calc(100vw - 48px)); padding: 14px 18px; border-left: 4px solid var(--mint); border-radius: 8px; color: white; background: var(--ink); box-shadow: var(--shadow); font-size: 13px; line-height: 1.5; }
.toast.error { border-left-color: var(--coral); }

@media (max-width: 920px) {
  .workspace { grid-template-columns: 320px minmax(0, 1fr); }
  .panel-section { padding: 23px; }
  .gallery-panel { padding: 28px 24px 50px; }
  .split-actions { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .topbar { height: 64px; padding: 0 18px; }
  .status-dot { display: none; }
  .workspace { display: block; }
  .control-panel { border-right: 0; }
  .panel-section { padding: 22px 18px; }
  .gallery-panel { padding: 25px 18px 50px; }
  .gallery-header { min-height: 0; display: block; }
  .selection-actions { padding: 0 0 20px; justify-content: space-between; }
  .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .image-info { padding: 11px; }
  .image-actions { grid-template-columns: 1fr; }
  .image-actions button { width: 100%; }
  .login-card { padding: 34px 26px; }
}

@media (max-width: 430px) {
  .gallery-grid { grid-template-columns: 1fr; }
  .mobile-card { padding: 23px; }
}

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