:root {
  --ink: #0b1730;
  --muted: #778197;
  --line: #e4e8ef;
  --canvas: #f7f8fa;
  --blue: #0f5ce8;
  --blue-soft: #edf4ff;
  --navy: #071426;
  --white: #fff;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; color: var(--ink); background: var(--canvas); font: 14px/1.5 Inter, "PingFang SC", "Microsoft YaHei", sans-serif; }
body.login-open { overflow: hidden; background: var(--white); }
button, input, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.login-gate { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: var(--white); }
.login-form { width: min(340px, calc(100vw - 40px)); }
.login-mark { display: block; width: 76px; height: 76px; object-fit: contain; margin: 0 auto 8px; }
.login-form h1 { margin: 0 0 38px; text-align: center; font-size: 32px; line-height: 1; letter-spacing: .12em; }
.login-form label { display: block; margin-bottom: 20px; }
.login-form label span { display: block; margin-bottom: 8px; color: #3d485f; font-size: 13px; font-weight: 600; }
.login-form input { width: 100%; height: 48px; padding: 0 14px; color: var(--ink); background: var(--white); border: 1px solid #cfd6e1; border-radius: 9px; outline: none; transition: border-color .16s, box-shadow .16s; }
.login-form input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(15, 92, 232, .12); }
.login-error { min-height: 22px; margin: -6px 0 8px; color: #c53737; font-size: 12px; }
.primary-button { height: 44px; padding: 0 18px; color: var(--white); background: var(--blue); border: 0; border-radius: 9px; font-weight: 700; cursor: pointer; transition: background .16s, transform .16s; }
.login-form .primary-button { width: 100%; height: 48px; }
.login-utility { min-height: 22px; display: flex; align-items: start; justify-content: space-between; margin: -6px 0 8px; }
.login-utility .login-error { margin: 0; }
.test-entry { padding: 3px 0; color: #8a94a6; background: transparent; border: 0; font-size: 12px; cursor: pointer; }
.test-entry:hover { color: var(--blue); }
.back-login { display: block; margin: 18px auto 0; padding: 3px 8px; color: #8a94a6; background: transparent; border: 0; font-size: 12px; cursor: pointer; }
.back-login:hover { color: var(--blue); }
.primary-button:hover { background: #0a4dca; }
.primary-button:active { transform: translateY(1px); }
.primary-button:disabled { opacity: .55; cursor: wait; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 88px minmax(0, 1fr); }
.sidebar { display: flex; flex-direction: column; align-items: center; gap: 34px; padding: 22px 12px; background: var(--white); border-right: 1px solid var(--line); }
.brand { display: grid; place-items: center; width: 48px; height: 48px; }
.brand img { width: 48px; height: 48px; object-fit: contain; }
.sidebar nav { width: 100%; display: grid; gap: 8px; }
.nav-button { width: 64px; min-height: 58px; display: grid; place-items: center; gap: 3px; padding: 7px 4px; color: #68758c; background: transparent; border: 0; border-radius: 10px; cursor: pointer; }
.nav-button svg, .viewer-toolbar svg, .empty-action svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav-button span { font-size: 11px; }
.nav-button:hover, .nav-button.active { color: var(--blue); background: var(--blue-soft); }

.workspace { min-width: 0; padding: clamp(20px, 3vw, 40px); }
.topbar { height: 52px; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.topbar h1 { margin: 0; font-size: 26px; line-height: 1.4; letter-spacing: -.03em; }
.top-actions { display: flex; align-items: center; gap: 14px; }
.primary-button.compact { height: 40px; font-size: 13px; }
.account { min-width: 40px; color: var(--muted); font-size: 13px; text-align: right; }

.reader-layout { height: calc(100vh - 130px); min-height: 560px; display: grid; grid-template-columns: minmax(0, 1fr) clamp(260px, 22vw, 340px); gap: 16px; }
.viewer-panel, .notes-panel { min-width: 0; overflow: hidden; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); }
.viewer-panel { display: grid; grid-template-rows: minmax(0, 1fr) 64px; }
.image-frame { position: relative; display: grid; place-items: center; overflow: hidden; margin: 8px 8px 0; background: var(--navy); border-radius: 8px; }
.image-frame img { max-width: 92%; max-height: 90%; object-fit: contain; transform-origin: center; transition: transform .18s, filter .18s; }
.empty-action { display: grid; justify-items: center; gap: 9px; padding: 14px 20px; color: #9daac0; background: transparent; border: 0; cursor: pointer; }
.empty-action:hover { color: var(--white); }
.image-frame:not(.empty) .empty-action { display: none; }
.viewer-toolbar { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; }
.viewer-toolbar button { width: 38px; height: 38px; display: grid; place-items: center; color: #4f5d74; background: transparent; border: 0; border-radius: 8px; font-size: 20px; cursor: pointer; }
.viewer-toolbar button:hover, .viewer-toolbar button.active { color: var(--blue); background: var(--blue-soft); }
.viewer-toolbar output { min-width: 48px; color: var(--muted); font-size: 12px; text-align: center; }
.viewer-toolbar i { width: 1px; height: 24px; margin: 0 10px; background: var(--line); }

.notes-panel { display: grid; grid-template-rows: 62px minmax(0, 1fr); }
.notes-heading { display: flex; align-items: center; justify-content: space-between; padding: 0 20px; border-bottom: 1px solid var(--line); }
.notes-heading h2 { margin: 0; font-size: 15px; }
.notes-heading span { color: #2c9a72; font-size: 11px; }
.notes-panel textarea { width: 100%; height: 100%; resize: none; padding: 18px 20px; color: var(--ink); background: var(--white); border: 0; outline: 0; line-height: 1.7; }
.notes-panel textarea::placeholder { color: #a6adba; }

.admin-shell { min-height: 100vh; background: var(--canvas); }
.admin-header { height: 74px; display: flex; align-items: center; justify-content: space-between; padding: 0 clamp(20px, 4vw, 60px); background: var(--white); border-bottom: 1px solid var(--line); }
.admin-header .brand, .admin-header .brand img { width: 46px; height: 46px; }
.admin-actions { display: flex; align-items: center; gap: 18px; color: var(--muted); font-size: 13px; }
.text-button, .row-action { padding: 7px 0; color: #55627a; background: transparent; border: 0; cursor: pointer; font-size: 13px; }
.text-button:hover, .row-action:hover { color: var(--blue); }
.admin-content { width: min(900px, calc(100vw - 40px)); margin: 0 auto; padding: clamp(38px, 7vw, 84px) 0; }
.admin-title { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 25px; }
.admin-title h1 { margin: 0; font-size: 27px; letter-spacing: -.03em; }
.management-panel { overflow: hidden; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); }
.management-panel table { width: 100%; border-collapse: collapse; text-align: left; }
.management-panel th, .management-panel td { height: 62px; padding: 0 24px; border-bottom: 1px solid var(--line); font-size: 13px; }
.management-panel th { height: 48px; color: var(--muted); font-size: 12px; font-weight: 600; }
.management-panel tr:last-child td { border-bottom: 0; }
.management-panel td:last-child, .management-panel th:last-child { text-align: right; }
.state-button { min-width: 54px; padding: 5px 8px; color: #68758c; background: #f2f4f7; border: 0; border-radius: 6px; font-size: 12px; cursor: pointer; }
.state-button.is-on { color: #167353; background: #e9f7f0; }

@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; grid-template-rows: 68px minmax(0, 1fr); }
  .sidebar { position: sticky; top: 0; z-index: 4; flex-direction: row; justify-content: space-between; gap: 12px; padding: 9px 14px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand, .brand img { width: 44px; height: 44px; }
  .sidebar nav { width: auto; display: flex; }
  .nav-button { width: 56px; min-height: 48px; padding: 4px; }
  .nav-button span { display: none; }
  .workspace { padding: 18px; }
  .reader-layout { height: auto; min-height: 0; grid-template-columns: 1fr; }
  .viewer-panel { height: 62vh; min-height: 430px; }
  .notes-panel { min-height: 280px; }
  .admin-header { padding: 0 18px; }
  .management-panel { overflow-x: auto; }
  .management-panel table { min-width: 600px; }
}

@media (max-width: 520px) {
  .topbar { height: auto; align-items: center; }
  .topbar h1 { font-size: 22px; }
  .account { display: none; }
  .primary-button.compact { padding: 0 12px; font-size: 12px; }
  .viewer-panel { height: 58vh; min-height: 380px; }
}

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