:root {
  color-scheme: light;
  --bg: #f8f9fd;
  --surface: #fff;
  --surface-soft: #f7f8fc;
  --surface-hover: #f2f3f8;
  --ink: #0a1022;
  --muted: #66708a;
  --line: #e4e7f0;
  --line-strong: #d7dce8;
  --primary: #6045f4;
  --primary-hover: #5139dc;
  --primary-soft: #f0ecff;
  --green: #178b5d;
  --green-soft: #e7f7f0;
  --red: #d93025;
  --red-soft: #fce8e6;
  --orange: #d96c00;
  --blue: #1a73e8;
  --shadow: 0 18px 55px rgba(24, 29, 52, .12);
  --shadow-card: 0 8px 24px rgba(24, 29, 52, .07);
  --radius-lg: 16px;
  --radius: 10px;
  --header-h: 60px;
  --sidebar-w: 210px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101321;
  --surface: #181c2d;
  --surface-soft: #1d2235;
  --surface-hover: #252b40;
  --ink: #f6f7fc;
  --muted: #acb3c8;
  --line: #2b3145;
  --line-strong: #3a425b;
  --primary: #8975ff;
  --primary-hover: #9b8aff;
  --primary-soft: #292145;
  --green: #55c997;
  --green-soft: #153c30;
  --red: #ff8a82;
  --red-soft: #45201f;
  --orange: #ffad5c;
  --blue: #82b5ff;
  --shadow: 0 18px 55px rgba(0, 0, 0, .42);
  --shadow-card: 0 8px 24px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; }

html { min-width: 320px; scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100dvh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body.modal-open { overflow: hidden; }
#app { min-height: 100dvh; }

* {
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--muted) 45%, transparent) transparent;
}

*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 45%, transparent);
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background-color: color-mix(in srgb, var(--muted) 68%, transparent); }

button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
img, video { display: block; max-width: 100%; }
svg { display: block; }
[hidden], .hidden { display: none !important; }

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 34%, transparent);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  left: 14px;
  top: -60px;
  z-index: 1000;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--surface);
}

.skip-link:focus { top: 10px; }

.app-header {
  position: relative;
  z-index: 70;
  height: var(--header-h);
  border-bottom: 0;
  background: var(--surface);
  backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 clamp(12px, 2.2vw, 30px);
}

.app-header.minimal { justify-content: flex-end; }
.header-spacer { flex: 1; }

.brand {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 11px;
  border-radius: 9px;
  font-size: 21px;
  font-weight: 750;
  letter-spacing: -.025em;
}

.app-icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
}

.app-icon svg { width: 21px; height: 21px; }

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

.header-link {
  min-height: 44px;
  padding: 0 13px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 650;
}

.header-link:hover, .header-link.active {
  color: var(--primary);
  background: var(--primary-soft);
}

.header-link svg { width: 18px; height: 18px; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.language-button {
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 20px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  cursor: pointer;
}

.language-button:hover { background: var(--surface-hover); color: var(--ink); }

.icon-button {
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.icon-button:hover { background: var(--surface-hover); }
.icon-button svg { width: 20px; height: 20px; }

.user-menu { position: relative; }

.user-trigger {
  min-height: 44px;
  max-width: 210px;
  padding: 3px 7px 3px 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
}

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

.avatar {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 800;
}

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

.menu-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 226px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.menu-summary {
  padding: 9px 10px 12px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
}

.menu-summary small { color: var(--muted); }

.menu-item {
  width: 100%;
  min-height: 44px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  text-align: left;
}

.menu-item:hover { background: var(--surface-hover); }
.menu-item.danger { color: var(--red); }
.menu-item svg { width: 18px; height: 18px; }

.button {
  min-height: 44px;
  padding: 0 17px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color .16s ease, border-color .16s ease, color .16s ease, transform .16s ease;
}

.button:hover {
  border-color: color-mix(in srgb, var(--primary) 42%, var(--line));
  background: var(--surface-hover);
}

.button:active { transform: translateY(1px); }
.button:disabled { opacity: .55; cursor: not-allowed; }
.button svg { width: 18px; height: 18px; }
.button.small { min-height: 36px; padding: 0 12px; font-size: 13px; }
.button.primary { border-color: var(--primary); background: var(--primary); color: #fff; }
.button.primary:hover { border-color: var(--primary-hover); background: var(--primary-hover); }
.button.soft { border-color: transparent; background: var(--primary-soft); color: var(--primary); }
.button.danger { border-color: color-mix(in srgb, var(--red) 35%, var(--line)); color: var(--red); }
.button.text { border-color: transparent; background: transparent; box-shadow: none; }
.button.full { width: 100%; }

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.field {
  display: grid;
  gap: 7px;
}

.field > span, .field > label {
  font-size: 13px;
  font-weight: 700;
}

.input, .select, .textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  padding: 0 13px;
}

.textarea { min-height: 96px; padding-block: 10px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: color-mix(in srgb, var(--muted) 80%, transparent); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); outline: 3px solid color-mix(in srgb, var(--primary) 14%, transparent); }

.badge {
  min-height: 26px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 750;
}

.badge.purple { background: var(--primary-soft); color: var(--primary); }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.red { background: var(--red-soft); color: var(--red); }

.home-page {
  position: relative;
  min-height: calc(100dvh - var(--header-h));
  background: var(--surface);
}

.home-footer {
  position: absolute;
  inset: auto 0 0;
  min-height: 48px;
  padding: 0 clamp(18px, 3vw, 40px);
  border-top: 0;
  background: transparent;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  font-size: 13px;
}

.google-stage {
  width: min(100% - 32px, 760px);
  margin: 0 auto;
  padding-top: clamp(72px, 15vh, 146px);
  transition: width .34s cubic-bezier(.2,.8,.2,1), padding .34s cubic-bezier(.2,.8,.2,1), margin .34s cubic-bezier(.2,.8,.2,1);
}

.home-page .google-stage { padding-bottom: 80px; }

.aryuki-mark {
  display: flex;
  align-items: baseline;
  justify-content: center;
  margin: 0 0 28px;
  font: 500 clamp(56px, 8vw, 88px)/1 Arial, sans-serif;
  letter-spacing: -0.065em;
  user-select: none;
  transition: font-size .34s cubic-bezier(.2,.8,.2,1), margin .34s cubic-bezier(.2,.8,.2,1);
}

.aryuki-mark.small {
  justify-content: flex-start;
  margin: 0 0 22px 12px;
  font-size: 31px;
}

.google-stage.compact .aryuki-mark {
  justify-content: flex-start;
  margin: 0;
  font-size: 31px;
}

.home-page .google-stage.compact {
  position: fixed;
  z-index: 90;
  inset: 0 0 auto;
  width: 100%;
  height: 84px;
  margin: 0;
  padding: 14px clamp(18px, 3vw, 42px);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 97%, transparent);
  backdrop-filter: blur(14px);
  display: grid;
  grid-template-columns: minmax(96px, 132px) minmax(280px, 720px) 1fr;
  align-items: center;
  gap: 20px;
}

.home-page .google-stage.compact .google-actions,
.home-page .google-stage.compact .search-hints,
.home-page .google-stage.compact .syntax-help {
  display: none;
}

.aryuki-mark span:nth-child(1), .aryuki-mark span:nth-child(4) { color: #4285f4; }
.aryuki-mark span:nth-child(2), .aryuki-mark span:nth-child(6) { color: #ea4335; }
.aryuki-mark span:nth-child(3) { color: #fbbc05; }
.aryuki-mark span:nth-child(5) { color: #34a853; }

.google-search-wrap { position: relative; }

.google-search {
  min-height: 52px;
  border: 1px solid #dadce0;
  border-radius: 26px;
  background: var(--surface);
  box-shadow: 0 3px 10px rgba(31, 31, 31, .08);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 0 18px;
}

[data-theme="dark"] .google-search { border-color: var(--line-strong); }

.google-search:focus-within, .google-search:hover {
  border-color: transparent;
  box-shadow: 0 3px 12px rgba(31, 31, 31, .2);
}

.google-search > svg { width: 20px; height: 20px; color: var(--muted); flex: 0 0 20px; }

.google-search input {
  min-width: 0;
  height: 48px;
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 16px;
}

.search-camera {
  color: #4285f4;
  flex: 0 0 44px;
}

.search-submit { color: var(--blue); }

.suggestions {
  position: absolute;
  z-index: 40;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  padding: 8px 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.suggestion {
  width: 100%;
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 13px;
  cursor: pointer;
  text-align: left;
}

.suggestion:hover, .suggestion.active { background: var(--surface-hover); }
.suggestion svg { width: 18px; height: 18px; color: var(--muted); }

.google-actions {
  display: flex;
  justify-content: center;
  gap: 11px;
  margin-top: 28px;
}

.google-action {
  min-height: 36px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: #f8f9fa;
  color: #202124;
  cursor: pointer;
}

.google-action:hover { border-color: #dadce0; box-shadow: 0 1px 1px rgba(0, 0, 0, .1); }
[data-theme="dark"] .google-action { background: var(--surface-soft); color: var(--ink); }

.search-hints {
  max-width: 650px;
  margin: 22px auto 0;
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}

.syntax-help {
  max-width: 560px;
  margin: 12px auto 0;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  text-align: left;
}

.syntax-help div {
  min-height: 32px;
  display: grid;
  grid-template-columns: 145px 1fr;
  align-items: center;
  gap: 14px;
}

.syntax-help code { color: var(--primary); }

.search-page {
  min-height: calc(100dvh - 84px);
  background: var(--surface);
}

.search-topbar {
  position: sticky;
  top: 0;
  z-index: 75;
  min-height: 84px;
  padding: 14px clamp(18px, 3vw, 42px);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  backdrop-filter: blur(12px);
  display: grid;
  grid-template-columns: minmax(96px, 132px) minmax(280px, 720px) 1fr;
  align-items: center;
  gap: 20px;
}

.search-wordmark { min-width: 0; }
.search-wordmark .aryuki-mark { margin: 0; }
.search-topbar-box { min-width: 0; }
.search-topbar .header-actions { justify-self: end; }

.search-layout {
  width: min(100% - 40px, 1120px);
  margin: 0 auto;
  padding: 22px 0 80px;
}

.search-summary { margin-bottom: 22px; color: var(--muted); }

.syntax-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.result-group {
  margin-bottom: 34px;
}

.result-group-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
}

.result-group h2 { margin: 0; font-size: 21px; }
.result-meta { color: var(--muted); }

.workspace {
  width: min(100% - 32px, 1680px);
  min-height: calc(100dvh - var(--header-h) - 28px);
  margin: 14px auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  overflow: clip;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: var(--surface-soft);
  padding: 20px 12px;
}

.sidebar-label {
  margin: 14px 14px 9px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.side-link {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  text-align: left;
}

.side-link:hover { background: var(--surface-hover); }
.side-link.active { background: var(--primary-soft); color: var(--primary); font-weight: 750; }
.side-link svg { width: 20px; height: 20px; }

.sidebar-storage {
  margin: 26px 8px 0;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.page {
  min-width: 0;
  padding: clamp(22px, 3vw, 42px);
}

.page-head {
  min-height: 64px;
  margin-bottom: 26px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 22px;
}

.page-head h1 { margin: 0 0 5px; font-size: clamp(28px, 3vw, 40px); letter-spacing: -.035em; line-height: 1.15; }
.page-head p { margin: 0; color: var(--muted); font-size: 16px; }
.page-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat { padding: 20px; }
.stat-label { color: var(--muted); }
.stat-value { margin-top: 8px; font-size: 27px; font-weight: 800; letter-spacing: -.03em; }

.storage-bar {
  height: 9px;
  margin: 10px 0 6px;
  border-radius: 999px;
  background: var(--surface-hover);
  overflow: hidden;
}

.storage-bar > span {
  display: block;
  width: var(--used, 0%);
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.table-card, .class-top-card { padding: 20px; }

.admin-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

.admin-table th, .admin-table td {
  min-height: 54px;
  padding: 13px 15px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.admin-table th {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .03em;
}

.admin-table tr:last-child td { border-bottom: 0; }
.admin-table tbody tr:hover { background: color-mix(in srgb, var(--primary-soft) 40%, transparent); }
.cell-main { font-weight: 750; }
.cell-sub { color: var(--muted); font-size: 13px; }
.row-actions { display: flex; gap: 7px; justify-content: flex-end; }

.visibility {
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.switch {
  position: relative;
  width: 46px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface-hover);
  cursor: pointer;
}

.switch::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 4px rgba(20, 28, 44, .25);
  transition: transform .16s ease;
}

.switch.on {
  border-color: var(--primary);
  background: var(--primary);
}

.switch.on::after { transform: translateX(20px); background: #fff; }
.check-label input:checked + .switch { border-color: var(--primary); background: var(--primary); }
.check-label input:checked + .switch::after { transform: translateX(20px); background: #fff; }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.photo-card {
  position: relative;
  aspect-ratio: 1.48 / 1;
  min-width: 0;
  padding: 0;
  border: 2px solid transparent;
  border-radius: var(--radius);
  background: var(--surface-soft);
  overflow: hidden;
  cursor: pointer;
}

.photo-card:hover { box-shadow: var(--shadow-card); }
.photo-card.selected { border-color: var(--primary); }

.photo-open-button {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.photo-card img { width: 100%; height: 100%; object-fit: cover; }

.photo-check {
  position: absolute;
  z-index: 2;
  left: 8px;
  top: 8px;
  width: 26px;
  height: 26px;
  border: 2px solid #fff;
  border-radius: 7px;
  background: rgba(255, 255, 255, .82);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .2);
  display: grid;
  place-items: center;
}

.photo-check.on { background: var(--primary); color: #fff; }
.photo-check.on::after { content: "✓"; font-weight: 900; }
.selection-toolbar {
  position: fixed;
  z-index: 55;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  width: min(100% - 28px, 980px);
  min-height: 68px;
  transform: translateX(-50%);
  padding: 10px 12px 10px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface) 95%, transparent);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.selection-toolbar .actions { display: flex; gap: 8px; }

.face-layout {
  display: grid;
  grid-template-columns: minmax(280px, 370px) minmax(0, 1fr);
  gap: 26px;
}

.camera-card { padding: 22px; }

.camera-frame {
  position: relative;
  aspect-ratio: 4 / 5;
  border-radius: 12px;
  background: #0d1020;
  overflow: hidden;
  display: grid;
  place-items: center;
}

.camera-frame video, .camera-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-frame video { transform: scaleX(-1); }

.camera-placeholder {
  max-width: 250px;
  padding: 24px;
  color: #d7dbea;
  text-align: center;
}

.camera-placeholder svg { width: 44px; height: 44px; margin: 0 auto 12px; }
.camera-placeholder strong, .camera-placeholder span { display: block; }
.camera-placeholder span { margin-top: 5px; color: #aeb7ce; }
.camera-actions {
  display: grid;
  gap: 9px;
  margin-top: 14px;
}
.camera-actions + .button.full { margin-top: 20px; }
.camera-actions.desktop { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.camera-actions.mobile { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.camera-actions > * {
  min-width: 0;
  width: 100%;
  padding-inline: 8px;
  justify-content: center;
  text-align: center;
}
.camera-actions .button { gap: 4px; font-size: 13px; white-space: nowrap; }
.camera-actions .button svg { width: 16px; height: 16px; flex: 0 0 16px; }
.camera-actions .button span { min-width: 0; overflow-wrap: anywhere; }
.camera-note { margin: 12px 0 0; color: var(--muted); font-size: 13px; }

.history-list { display: grid; gap: 12px; }

.history-item {
  padding: 17px 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
}

.history-summary { min-width: 0; display: flex; align-items: center; gap: 14px; }
.history-icon {
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  display: grid;
  place-items: center;
}

.history-icon svg { width: 20px; height: 20px; }
.history-summary > div:last-child { min-width: 0; flex: 1; }
.history-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 750; }
.history-meta { color: var(--muted); font-size: 13px; }
.history-photo-panel {
  grid-column: 1 / -1;
  width: 100%;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.history-photo-panel .photo-grid {
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 8px;
}

.save-section + .save-section { margin-top: 28px; }
.save-section-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 13px; }
.save-section h2 { margin: 0; font-size: 21px; }

.class-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.class-card { padding: 18px; }
.class-card h3 { margin: 0 0 5px; }
.class-card p { margin: 0; color: var(--muted); }
.class-card-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 16px; }
.owned-photo-panel {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.owned-photo-panel[hidden] { display: none; }
.owned-photo-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.owned-photo-panel .photo-grid {
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
}

.share-layout {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 20px;
  align-items: stretch;
}

.share-layout > .card { width: 100%; height: 100%; margin: 0; align-self: stretch; }

.share-list { padding: 8px; }

.share-row {
  width: 100%;
  padding: 14px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  display: grid;
  gap: 4px;
  cursor: pointer;
  text-align: left;
}

.share-row:hover, .share-row.active { background: var(--primary-soft); }
.share-row small { color: var(--muted); }
.share-editor { padding: 22px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.span-2 { grid-column: 1 / -1; }

.share-picker {
  max-height: 430px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.share-class { border-bottom: 1px solid var(--line); }
.share-class:last-child { border-bottom: 0; }

.share-class-head {
  min-height: 50px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface-soft);
}
.share-class-head > .row-actions { flex: 0 0 auto; }
.share-check-label { min-width: 0; }

.share-photo-list {
  padding: 10px 12px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.check-label {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 9px;
}

.check-label input { width: 18px; height: 18px; accent-color: var(--primary); }
.check-label .switch-input { position: absolute; width: 46px; height: 26px; opacity: 0; }
.check-label .switch-input:focus-visible + .switch,
.visibility-choice input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--primary) 34%, transparent); outline-offset: 2px; }

.permission-options {
  display: grid;
  gap: 8px;
}

.permission-option {
  min-height: 64px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.permission-option:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.permission-option input { margin-top: 4px; accent-color: var(--primary); }
.permission-option small { display: block; color: var(--muted); }

.visibility-segmented {
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

.visibility-choice { min-width: 0; cursor: pointer; }
.visibility-choice input { position: absolute; opacity: 0; pointer-events: none; }

.visibility-choice > span {
  min-height: 76px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 9px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 8px;
}

.visibility-choice svg { width: 19px; height: 19px; color: var(--muted); }
.visibility-choice small { grid-column: 1 / -1; color: var(--muted); }
.visibility-choice input:checked + span { border-color: var(--primary); background: var(--surface); box-shadow: 0 2px 8px rgba(24, 29, 52, .08); }
.visibility-choice input:checked + span svg, .visibility-choice input:checked + span strong { color: var(--primary); }

.empty, .error-state, .loading-state {
  min-height: 220px;
  padding: 36px 22px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
}

.empty svg, .error-state svg { width: 34px; height: 34px; }
.error-state { color: var(--red); }
.loading-state::before {
  content: "";
  width: 28px;
  height: 28px;
  border: 3px solid var(--line);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

.public-share {
  width: min(100% - 32px, 1180px);
  margin: 32px auto 70px;
}

.public-share-head { padding: 24px; margin-bottom: 20px; }
.public-share-head h1 { margin: 0 0 7px; }

.dialog {
  width: min(100% - 28px, 560px);
  max-height: min(88dvh, 760px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  overflow: auto;
}

.dialog[open] { animation: dialog-in .22s cubic-bezier(.2,.8,.2,1); }
.dialog::backdrop { background: rgba(8, 11, 24, .62); backdrop-filter: blur(4px); animation: backdrop-in .2s ease-out; }
.dialog-head { padding: 20px 22px 14px; display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.dialog-head h2 { margin: 0; font-size: 22px; }
.dialog-body { padding: 4px 22px 20px; display: grid; gap: 14px; }
.dialog-actions { padding: 14px 22px 20px; display: flex; justify-content: flex-end; gap: 9px; }

.lightbox {
  width: min(100% - 28px, 1240px);
  height: min(88dvh, 820px);
}

.lightbox-body {
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
}

.lightbox-media {
  position: relative;
  min-height: 340px;
  background: #090b12;
  display: grid;
  place-items: center;
  overflow: hidden;
  touch-action: none;
  cursor: zoom-in;
}

.lightbox-media.zoomed { cursor: grab; }
.lightbox-media.zoomed:active { cursor: grabbing; }
.lightbox-media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform-origin: center;
  will-change: transform;
  user-select: none;
  -webkit-user-drag: none;
  transition: opacity .12s ease-out;
}
.lightbox-media.loading-preview img { opacity: 0; }
.lightbox-media.loading-preview .lightbox-preview-button { opacity: 0; pointer-events: none; }
.lightbox-preview-button {
  position: absolute;
  z-index: 3;
  left: 14px;
  bottom: 14px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, .34);
  border-radius: 999px;
  background: rgba(12, 15, 24, .66);
  color: #fff;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .2);
  backdrop-filter: blur(10px);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
}
.lightbox-preview-button:hover { background: rgba(12, 15, 24, .82); }
.lightbox-preview-button:focus-visible { outline: 3px solid rgba(255, 255, 255, .7); outline-offset: 2px; }
.lightbox-preview-button svg { width: 18px; height: 18px; }
.lightbox-info { padding: 26px; overflow: auto; background: var(--surface); }
.lightbox-info h2 { margin: 0 0 6px; }
.photo-metadata { margin: 18px 0 0; display: grid; gap: 9px; }
.photo-metadata > div { min-width: 0; display: grid; grid-template-columns: 90px minmax(0, 1fr); gap: 10px; }
.photo-metadata dt { color: var(--muted); }
.photo-metadata dd { min-width: 0; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lightbox-actions { display: grid; gap: 9px; margin-top: 24px; }
.lightbox-arrow { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,.88); color: #111; }
.lightbox-arrow.prev { left: 14px; }
.lightbox-arrow.next { right: 14px; }
.lightbox-close { position: absolute; right: 14px; top: 14px; background: rgba(255,255,255,.88); color: #111; }

.toast-root {
  position: fixed;
  z-index: 110;
  right: 20px;
  bottom: 20px;
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.toast {
  max-width: 360px;
  padding: 12px 15px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--ink);
  color: var(--surface);
  box-shadow: var(--shadow);
  animation: toast-in .18s ease-out;
}

.toast.error { background: #8d1d16; color: #fff; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes dialog-in { from { opacity: 0; transform: translateY(12px) scale(.985); } }
@keyframes backdrop-in { from { opacity: 0; } }
@keyframes sheet-in { from { transform: translateY(100%); } }

@media (max-width: 1180px) {
  .photo-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .class-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .share-layout { grid-template-columns: 1fr; }
  .share-layout > .card { height: auto; }
}

@media (max-width: 860px) {
  :root { --header-h: 62px; }
  .app-header { padding-inline: 12px; }
  .user-name { display: none; }
  .workspace { width: 100%; min-height: calc(100dvh - var(--header-h)); margin: 0; border: 0; border-radius: 0; grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 60; inset: auto 0 0; padding: 5px max(4px, env(safe-area-inset-right)) max(0px, calc(env(safe-area-inset-bottom) - 8px)) max(4px, env(safe-area-inset-left)); border: 1px solid var(--line); border-bottom: 0; display: flex; overflow: hidden; background: color-mix(in srgb, var(--surface) 96%, transparent); backdrop-filter: blur(14px); }
  .sidebar-label, .sidebar-storage { display: none; }
  .side-link { min-width: 0; min-height: 52px; padding: 5px 2px; flex: 1 1 0; justify-content: center; }
  .side-link span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .side-link svg { width: 21px; height: 21px; }
  .page { padding: 22px 16px calc(104px + env(safe-area-inset-bottom)); }
  .face-layout { grid-template-columns: 1fr; }
  .search-layout { width: calc(100% - 24px); }
  .home-page .google-stage.compact {
    grid-template-columns: 86px minmax(0, 1fr);
    padding-inline: 14px;
  }
  .search-topbar {
    min-height: 132px;
    padding: 10px 12px 14px;
    grid-template-columns: minmax(70px, 1fr) auto;
    grid-template-areas: "logo actions" "search search";
    gap: 8px 10px;
  }
  .search-wordmark { grid-area: logo; }
  .search-topbar-box { grid-area: search; }
  .search-topbar .header-actions { grid-area: actions; display: flex; }
  .lightbox { width: 100%; height: 100dvh; max-height: none; border: 0; border-radius: 0; }
  .lightbox-body { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; overflow: hidden; }
  .lightbox-media { min-height: 0; }
  .lightbox-info { max-height: 34dvh; padding: 16px; overflow: auto; }
  .lightbox-info h2 { font-size: 18px; }
  .lightbox-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 12px; }
  .lightbox-actions .button {
    min-width: 0;
    padding-inline: 6px;
    gap: 5px;
    font-size: 12px;
    white-space: nowrap;
  }
  .lightbox-actions .button svg { width: 16px; height: 16px; }
  .selection-toolbar { z-index: 65; bottom: max(8px, env(safe-area-inset-bottom)); }
  .selection-toolbar.with-mobile-nav { bottom: calc(68px + env(safe-area-inset-bottom)); }
}

@media (max-width: 620px) {
  .brand { font-size: 18px; }
  .app-icon { width: 34px; height: 34px; }
  .header-actions { gap: 1px; }
  .history-button, .app-header .icon-button { width: 40px; height: 40px; }
  .user-trigger { padding-inline: 2px; }
  .google-stage { width: calc(100% - 24px); padding-top: 64px; }
  .aryuki-mark { font-size: 59px; margin-bottom: 24px; }
  .google-actions { flex-wrap: wrap; }
  .syntax-help div { grid-template-columns: 1fr; gap: 0; padding: 5px 0; }
  .page-head { display: grid; }
  .page-actions { width: 100%; }
  .page-actions .button { flex: 1; }
  .stats, .class-list, .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .selection-toolbar { align-items: stretch; flex-direction: column; }
  .selection-toolbar .actions { display: grid; grid-template-columns: repeat(3, 1fr); }
  .selection-toolbar .actions .button { padding-inline: 8px; font-size: 12px; }
  .history-item { grid-template-columns: 1fr; align-items: stretch; }
  .history-item .row-actions { justify-content: flex-start; }
  .result-group-head { align-items: center; gap: 9px; }
  .result-group-head > .row-actions { flex-wrap: wrap; }
  .share-photo-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .visibility-segmented { grid-template-columns: 1fr; }
  .confirm-dialog {
    width: 100%;
    max-height: min(72dvh, 620px);
    margin: auto 0 0;
    border-width: 1px 0 0;
    border-radius: 20px 20px 0 0;
    animation: sheet-in .26s cubic-bezier(.2,.8,.2,1) !important;
  }
  .confirm-dialog .dialog-actions {
    padding-bottom: max(20px, env(safe-area-inset-bottom));
  }
  .confirm-dialog .dialog-actions .button { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Auth Center modal shell */
.modal-overlay {
  position: fixed;
  z-index: 2147483647;
  inset: 0;
  padding: 18px;
  background: rgba(8, 11, 24, .62);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: backdrop-in .2s ease-out;
  overscroll-behavior: contain;
}

.modal-overlay .dialog {
  margin: 0;
  display: block;
  animation: dialog-in .22s cubic-bezier(.2,.8,.2,1);
}

.dialog > form {
  max-height: inherit;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.dialog-head {
  position: sticky;
  z-index: 4;
  top: 0;
  background: var(--surface);
}

.dialog-body {
  min-width: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

.confirm-dialog .badge.red {
  width: 100%;
  min-height: 50px;
  margin: 8px 0 2px;
  padding: 13px 16px;
  border-radius: 10px;
  justify-content: center;
  font-size: 16px;
  font-weight: 850;
}

/* Compact storage rows */
.storage-class-list { display: grid; grid-template-columns: 1fr; gap: 10px; }
.storage-class-row { padding: 14px 16px; min-width: 0; }
.storage-class-summary {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto;
  align-items: center;
  gap: 14px;
}
.storage-class-title { min-width: 0; }
.storage-class-title h3 { margin: 0; overflow-wrap: anywhere; }
.storage-class-title p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}
.storage-class-metric { display: grid; gap: 2px; }
.storage-class-metric small { color: var(--muted); }
.storage-class-meta {
  display: grid;
  grid-template-columns: auto auto auto;
  align-items: center;
  gap: 14px;
}
.storage-class-row .row-actions { flex-wrap: wrap; }
.storage-overview + .save-section { margin-top: 34px; }
.storage-meter-label { padding: 0 20px 20px; }
.storage-overview .stat-value,
.account-overview .stat-value { font-weight: 620; }
.storage-overview strong,
.account-overview strong { font-weight: 650; }
.account-overview .badge { white-space: nowrap; }
.account-overview .badge svg { width: 18px; height: 18px; }
.saved-photo-groups { display: grid; gap: 14px; }
.saved-photo-group { padding: 16px; min-width: 0; }
.saved-photo-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.saved-photo-group h3, .saved-photo-group p { margin: 0; }
.saved-photo-group p { color: var(--muted); font-size: 13px; }
.saved-photo-group-title { min-width: 0; }
.saved-photo-group-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.saved-photo-panel {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.saved-photo-panel .photo-grid {
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 7px;
}
.sort-field { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.select.compact { width: auto; min-height: 36px; padding-inline: 9px 28px; }
.stats.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* Share picker and custom calendar */
.share-picker-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.share-photo-choice {
  position: relative;
  aspect-ratio: 1.35;
  min-width: 0;
  border: 2px solid transparent;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
}
.share-photo-choice:has(input:checked) { border-color: var(--primary); }
.choice-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.share-check-label { position: relative; -webkit-tap-highlight-color: transparent; }
.share-password-toggle {
  width: max-content;
  max-width: 100%;
  background: transparent;
  box-shadow: none;
  -webkit-tap-highlight-color: transparent;
}
.share-password-toggle:hover,
.share-password-toggle:active,
.share-password-toggle:focus-within { background: transparent; box-shadow: none; }
.share-password-toggle .switch-input:focus-visible + .switch {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 34%, transparent);
}
.share-check-label > .photo-check {
  position: relative;
  inset: auto;
  flex: 0 0 26px;
}
.share-photo-choice > .photo-check { left: 6px; top: 6px; }
.share-photo-choice:has(.choice-input:disabled) { opacity: .56; cursor: not-allowed; }
.share-photo-choice img { width: 100%; height: 100%; object-fit: cover; }
.share-password-owner {
  min-height: 44px;
  padding: 4px 5px 4px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.share-password-owner > button:first-child {
  min-width: 0;
  flex: 1;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: text;
}
.share-password-owner code { overflow-wrap: anywhere; }
.copied { color: var(--green) !important; border-color: color-mix(in srgb, var(--green) 45%, var(--line)) !important; }
.date-time-field { position: relative; }
.date-trigger {
  width: 100%;
  min-height: 44px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}
.date-popover {
  position: absolute;
  z-index: 30;
  top: calc(100% + 7px);
  left: 0;
  width: min(340px, calc(100vw - 44px));
  max-height: min(500px, 70dvh);
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: auto;
}
.calendar-head {
  display: grid;
  grid-template-columns: 38px minmax(90px, 1fr) minmax(84px, 1fr) 38px;
  align-items: center;
  gap: 5px;
}
.calendar-head .icon-button { width: 36px; height: 36px; }
.calendar-week, .calendar-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 3px;
}
.calendar-week { margin: 10px 0 4px; color: var(--muted); font-size: 11px; text-align: center; }
.calendar-day {
  aspect-ratio: 1;
  min-width: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
}
.calendar-day:hover { background: var(--surface-hover); }
.calendar-day.outside { color: color-mix(in srgb, var(--muted) 55%, transparent); }
.calendar-day.selected { background: var(--primary); color: #fff; font-weight: 800; }
.calendar-foot {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.calendar-foot label { display: flex; align-items: center; gap: 4px; font-size: 12px; }
.calendar-foot .select { min-width: 58px; padding-inline: 6px; }

/* Account-managed home background */
#app.has-home-background {
  background-image: linear-gradient(rgba(5, 10, 24, .24), rgba(5, 10, 24, .24)), var(--home-background);
  background-position: center;
  background-size: cover;
  background-attachment: fixed;
}
#app.has-home-background .app-header,
#app.has-home-background .home-page { background: transparent; }
#app.has-home-background .app-header { backdrop-filter: none; }
#app.has-home-background .google-stage {
  position: relative;
  z-index: 1;
}
#app.has-home-background .home-page .google-stage.compact {
  position: fixed;
  background: transparent;
  border-bottom-color: transparent;
  backdrop-filter: none;
}
#app.has-home-background .google-search,
#app.has-home-background .syntax-help {
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(15px);
}
#app.has-home-background .search-hints {
  width: fit-content;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(8, 11, 24, .58);
  color: #fff;
}
#app.has-home-background .google-action {
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  color: var(--ink);
  backdrop-filter: blur(12px);
}
#app.has-home-background .home-footer {
  background: transparent;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .72);
  backdrop-filter: none;
}
#app.has-home-background .header-actions > .icon-button,
#app.has-home-background .header-actions > .language-button,
#app.has-home-background .user-trigger {
  border: 1px solid rgba(255, 255, 255, .68);
  background: transparent;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .72);
  backdrop-filter: none;
}
#app.has-home-background .header-actions > .icon-button:hover,
#app.has-home-background .header-actions > .language-button:hover,
#app.has-home-background .user-trigger:hover { background: rgba(0, 0, 0, .16); }
.account-bindings { padding: 0 20px 20px; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.account-background-card { margin-top: 20px; padding: 20px; }
.account-background-settings { display: grid; gap: 16px; }
.account-background-copy h2,
.account-background-copy p { margin: 0; }
.account-background-copy h2 { font-size: 20px; font-weight: 650; }
.account-background-copy p { margin-top: 4px; color: var(--muted); }
.background-mode-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}
.background-mode-choice {
  min-width: 0;
  min-height: 72px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
  display: grid;
  gap: 3px;
  text-align: left;
}
.background-mode-choice strong { font-weight: 650; }
.background-mode-choice small { color: var(--muted); }
.background-mode-choice.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}
.background-settings-preview {
  aspect-ratio: 16 / 5;
  min-height: 130px;
  border-radius: 14px;
  background: var(--surface-soft);
  background-position: center;
  background-size: cover;
  display: grid;
  place-items: center;
  color: var(--muted);
}
.background-settings-preview span { display: inline-flex; align-items: center; gap: 7px; }
.background-settings-preview svg { width: 20px; height: 20px; }
.background-settings-actions { display: flex; justify-content: flex-end; }
.background-preview {
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft) center / cover no-repeat;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.background-preview span { color: var(--muted); display: grid; place-items: center; gap: 8px; }
.background-preview svg { width: 34px; height: 34px; }
.background-actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.background-actions .button { min-width: 0; padding-inline: 8px; }
.background-crop-dialog { width: min(100% - 28px, 820px); }
.background-crop-canvas {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  background: #0a0d16;
}
.crop-controls { display: grid; gap: 10px; }
.crop-controls input[type="range"] { width: 100%; accent-color: var(--primary); }
.crop-controls input[data-crop-axis] {
  height: 18px;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
}
.crop-controls input[data-crop-axis]::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(to right,
    var(--line-strong) 0 var(--range-start, 50%),
    var(--primary) var(--range-start, 50%) var(--range-end, 50%),
    var(--line-strong) var(--range-end, 50%) 100%);
}
.crop-controls input[data-crop-axis]::-webkit-slider-thumb {
  width: 18px;
  height: 18px;
  margin-top: -6.5px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  appearance: none;
  -webkit-appearance: none;
  background: var(--primary);
  box-shadow: 0 1px 4px rgba(24, 29, 52, .24);
}
.crop-controls input[data-crop-axis]::-moz-range-track {
  height: 5px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(to right,
    var(--line-strong) 0 var(--range-start, 50%),
    var(--primary) var(--range-start, 50%) var(--range-end, 50%),
    var(--line-strong) var(--range-end, 50%) 100%);
}
.crop-controls input[data-crop-axis]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--primary);
}
.crop-controls input[data-crop-axis]:disabled { opacity: .7; }
.crop-controls input[data-crop-axis]:disabled::-webkit-slider-runnable-track,
.crop-controls input[data-crop-axis]:disabled::-moz-range-track { background: var(--line-strong); }
.crop-controls input[data-crop-axis]:disabled::-webkit-slider-thumb,
.crop-controls input[data-crop-axis]:disabled::-moz-range-thumb { background: var(--muted); }

.upload-progress {
  position: fixed;
  z-index: 80;
  right: 18px;
  bottom: 18px;
  width: min(310px, calc(100vw - 24px));
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface) 95%, transparent);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}
.upload-progress-head,
.upload-progress-head > span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.upload-progress-head > span { justify-content: flex-start; }
.upload-progress-head svg { width: 18px; height: 18px; }
.upload-progress-bar {
  height: 6px;
  margin: 10px 0 5px;
  border-radius: 999px;
  background: var(--surface-soft);
  overflow: hidden;
}
.upload-progress-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width .2s ease;
}
.upload-progress.error { color: var(--red); }
.upload-progress.error .upload-progress-bar span { background: var(--red); }
.upload-progress-mini {
  position: fixed;
  z-index: 80;
  right: 18px;
  bottom: 18px;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
}
.upload-progress-mini svg { width: 22px; height: 22px; }

.audit-list { display: grid; gap: 12px; }
.audit-user-card { padding: 16px; }
.audit-user-head,
.audit-uuid-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.audit-user-head h3 { margin: 0; }
.audit-uuid-line { justify-content: flex-start; margin-top: 4px; color: var(--muted); }
.audit-uuid { max-width: min(64vw, 620px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audit-uuid-line .icon-button { width: 30px; height: 30px; }
.audit-panel {
  margin-top: 13px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
.audit-row {
  min-width: 0;
  padding: 9px 4px;
  display: grid;
  grid-template-columns: minmax(130px, 1fr) minmax(160px, .8fr) minmax(150px, .8fr) auto;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--line);
}
.audit-row:last-child { border-bottom: 0; }
.audit-row.sensitive { color: var(--red); background: var(--red-soft); border-radius: 8px; padding-inline: 9px; }
.audit-row code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audit-action { min-width: 0; display: grid; gap: 3px; }
.audit-target-line { min-width: 0; display: flex; align-items: center; gap: 4px; color: currentColor; opacity: .82; }
.audit-target { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.audit-target-line .icon-button { width: 28px; height: 28px; flex: 0 0 28px; }
.audit-target-line .icon-button svg { width: 15px; height: 15px; }
.audit-target,
.audit-detail { color: currentColor; }
.audit-target[href],
.audit-detail[href],
.audit-photo-link { text-decoration: underline; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); text-underline-offset: 3px; }
button.audit-target,
button.audit-detail {
  padding: 0;
  border: 0;
  background: transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.audit-detail-cell { min-width: 0; display: grid; gap: 3px; }
.audit-detail { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.audit-ip-address { display: none; font-size: 12px; }
.audit-list.show-ip .audit-ip-address { display: block; }
.audit-ip-toggle { display: inline-flex; align-items: center; gap: 9px; color: var(--muted); white-space: nowrap; }

.upload-filter-card {
  padding: 20px;
  margin-bottom: 20px;
}
.upload-filter-head,
.upload-range-label,
.upload-user-head,
.upload-user-summary,
.upload-stored-line {
  display: flex;
  align-items: center;
}
.upload-filter-head {
  justify-content: space-between;
  gap: 18px;
}
.upload-filter-head h2,
.upload-user-identity h3 { margin: 0; }
.upload-filter-head p {
  max-width: 760px;
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.55;
}
.upload-filter-head .visibility { flex: 0 0 auto; }
.upload-filter-form {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 260px)) auto;
  align-items: end;
  gap: 12px;
}
.upload-filter-actions {
  display: flex;
  gap: 8px;
}
.upload-range-label {
  min-width: 0;
  margin-bottom: 12px;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}
.upload-stats { margin-bottom: 18px; }
.upload-user-list { display: grid; gap: 12px; }
.upload-user-card { min-width: 0; padding: 16px; }
.upload-user-head {
  min-width: 0;
  justify-content: space-between;
  gap: 18px;
}
.upload-user-identity { min-width: 0; }
.upload-user-summary {
  flex: 0 0 auto;
  gap: clamp(14px, 3vw, 34px);
}
.upload-user-summary > span {
  min-width: 68px;
  display: grid;
  gap: 2px;
}
.upload-user-summary strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
}
.upload-user-summary small,
.upload-record-row small { color: var(--muted); }
.upload-record-panel {
  min-width: 0;
  min-height: 0;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.upload-record-panel.loading-state { min-height: 150px; }
.upload-record-head,
.upload-record-row {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(220px, 1.45fr) minmax(150px, .9fr) minmax(210px, 1.15fr) minmax(110px, .55fr);
  align-items: center;
  gap: 12px;
}
.upload-record-head {
  padding: 3px 8px 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.upload-record-row {
  padding: 10px 8px;
  border-top: 1px solid var(--line);
}
.upload-record-files,
.upload-record-actor,
.upload-record-size,
.upload-record-status {
  min-width: 0;
  display: grid;
  gap: 4px;
}
.upload-file-name,
.upload-stored-line code,
.upload-record-status small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.upload-stored-line { min-width: 0; gap: 4px; }
.upload-stored-line code { display: block; color: var(--muted); }
.upload-stored-line .icon-button {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
}
.upload-stored-line .icon-button svg { width: 15px; height: 15px; }
.upload-record-status .badge { justify-self: start; }
.upload-record-status small { color: var(--red); }

@media (max-width: 980px) {
  .storage-class-summary {
    grid-template-columns: minmax(180px, 1fr) auto;
  }
  .storage-class-title { grid-column: 1 / -1; }
  .storage-class-summary .row-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .upload-user-head { align-items: flex-start; }
  .upload-user-summary { flex-wrap: wrap; justify-content: flex-end; }
  .upload-record-head { display: none; }
  .upload-record-row {
    grid-template-columns: minmax(0, 1.35fr) minmax(150px, .8fr);
    align-items: start;
  }
}

@media (max-width: 620px) {
  .app-header { height: 54px; min-height: 54px; }
  :root { --header-h: 54px; }
  .page { padding: 16px 10px calc(96px + env(safe-area-inset-bottom)); }
  .page-head { min-height: 0; margin-bottom: 16px; gap: 10px; }
  .page-head {
    display: flex;
    align-items: flex-start;
    flex-wrap: wrap;
  }
  .page-head > div:first-child { min-width: 0; flex: 1; }
  .page-head > .page-actions { width: auto; flex: 0 0 auto; }
  .page-head > .page-actions .button { flex: none; }
  .page-head h1 { font-size: 27px; }
  .page-head p { font-size: 13px; }
  .card { border-radius: 12px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
  .stats.three { grid-template-columns: 1fr; }
  .stat { padding: 14px; }
  .stat-value { margin-top: 3px; font-size: 22px; }
  .save-section + .save-section { margin-top: 20px; }
  .save-section-head { align-items: flex-start; margin-bottom: 10px; }
  .save-section-head .page-actions { width: auto; justify-content: flex-end; }
  .managed-class-actions { display: flex; flex-wrap: nowrap; align-items: center; }
  .managed-class-filter { min-width: 0; }
  .managed-class-filter > span { display: none; }
  .managed-class-filter .select { min-width: 112px; }
  .save-section-head h2 { font-size: 19px; }
  .save-section-head > .result-meta { margin-right: 4px; }
  .storage-class-row { padding: 12px; }
  .storage-class-summary { grid-template-columns: minmax(0, 1fr); gap: 9px; }
  .storage-class-title { grid-column: 1 / -1; }
  .storage-class-meta {
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }
  .storage-class-metric { min-width: 0; }
  .storage-class-meta > [data-visibility-shell] { min-width: 0; justify-self: end; }
  .storage-class-meta .visibility { gap: 5px; font-size: 12px; }
  .storage-class-summary .row-actions { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); width: 100%; }
  .storage-class-summary .row-actions .button { min-width: 0; padding-inline: 6px; }
  .saved-photo-group { padding: 10px; }
  .saved-photo-group-head { align-items: stretch; display: grid; gap: 8px; }
  .saved-photo-group-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 5px;
  }
  .saved-photo-group-actions .result-meta { white-space: nowrap; font-size: 12px; }
  .saved-section-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 6px;
  }
  .saved-section-actions .sort-field { min-width: 0; }
  .saved-section-actions .sort-field > span { display: none; }
  .saved-section-actions .select { width: 100%; min-width: 0; }
  .saved-section-actions .button span { white-space: nowrap; }
  .saved-photo-group .photo-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
  .owned-photo-panel .photo-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
  .share-editor { padding: 14px 10px; }
  .share-editor > form > .dialog-actions .button {
    min-width: 0;
    padding-inline: 5px;
    gap: 4px;
    font-size: 12px;
    white-space: nowrap;
  }
  .share-editor > form > .dialog-actions .button svg { width: 16px; height: 16px; }
  .share-class-head { padding: 7px 8px; gap: 7px; }
  .share-class-head > .row-actions { gap: 4px; }
  .share-class-head > .row-actions .button { min-width: 0; padding-inline: 7px; font-size: 11px; }
  .share-photo-list { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; padding: 8px; }
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal-overlay .dialog:not(.lightbox) {
    width: 100%;
    max-height: min(88dvh, 760px);
    border-width: 1px 0 0;
    border-radius: 20px 20px 0 0;
    animation: sheet-in .26s cubic-bezier(.2,.8,.2,1);
  }
  .dialog-head { padding: 15px 14px 9px; }
  .dialog-head h2 { font-size: 19px; }
  .dialog-head .icon-button { width: 40px; height: 40px; flex: 0 0 40px; }
  .dialog-body { padding: 4px 14px 15px; }
  .dialog-actions {
    padding: 10px 14px max(14px, env(safe-area-inset-bottom));
    background: var(--surface);
  }
  .dialog-actions .button { flex: 1; min-width: 0; }
  .lightbox { width: 100%; height: 100dvh; max-height: 100dvh; }
  .background-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .date-popover {
    position: fixed;
    z-index: 2147483647;
    inset: auto 8px max(8px, env(safe-area-inset-bottom));
    width: auto;
    max-height: 74dvh;
  }
  .search-topbar { min-height: 116px; }
  .search-layout { width: calc(100% - 16px); padding-top: 12px; }
  .selection-toolbar { width: calc(100% - 16px); }
  .history-item { padding: 12px; gap: 9px; }
  .app-header .language-button { width: 40px; height: 40px; flex: 0 0 40px; }
  .history-summary { align-items: flex-start; gap: 9px; }
  .history-item .row-actions { width: 100%; flex-wrap: nowrap; }
  .history-item .row-actions .button { min-width: 0; flex: 1; padding-inline: 6px; }
  .history-photo-panel,
  .history-item > .history-photo-panel:last-child { grid-column: 1 / -1; }
  .history-photo-panel .photo-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
  .background-mode-grid { gap: 5px; }
  .background-mode-choice { min-height: 76px; padding: 8px 6px; font-size: 12px; }
  .background-mode-choice small { font-size: 10px; line-height: 1.25; }
  .background-settings-preview { min-height: 100px; aspect-ratio: 16 / 7; }
  .background-settings-actions .button { width: 100%; }
  .upload-progress,
  .upload-progress-mini { right: 10px; bottom: calc(72px + env(safe-area-inset-bottom)); }
  .audit-user-head { align-items: flex-start; }
  .audit-uuid { max-width: 46vw; }
  .audit-row { grid-template-columns: minmax(0, 1fr) auto; gap: 5px 8px; font-size: 12px; }
  .audit-row code { white-space: normal; overflow-wrap: anywhere; }
  .upload-filter-card { padding: 14px 10px; }
  .upload-filter-head { align-items: flex-start; gap: 10px; }
  .upload-filter-head p { font-size: 12px; }
  .upload-filter-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .upload-filter-actions { grid-column: 1 / -1; }
  .upload-filter-actions .button { min-width: 0; flex: 1; }
  .upload-range-label {
    align-items: flex-start;
    flex-direction: column;
  }
  .upload-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .upload-stats .stat { padding: 13px 11px; }
  .upload-stats .stat-value { font-size: 20px; }
  .upload-user-card { padding: 12px 9px; }
  .upload-user-head { display: grid; gap: 10px; }
  .upload-user-summary {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(46px, auto);
    align-items: end;
    gap: 6px;
  }
  .upload-user-summary > span { min-width: 0; }
  .upload-user-summary strong,
  .upload-user-summary small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .upload-user-summary .button { min-width: 0; padding-inline: 6px; }
  .upload-record-row {
    padding: 10px 2px;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 9px 7px;
    font-size: 12px;
  }
  .upload-record-files { grid-column: 1 / -1; }
  .upload-record-size { min-width: 0; }
  .upload-record-status { align-items: end; text-align: right; }
  .upload-record-status small { max-width: 42vw; }
  .upload-stored-line code { max-width: calc(100vw - 104px); }
  html[lang="zh-CN"] .class-top-card .page-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }
  html[lang="zh-CN"] .class-top-card .page-actions > .button:first-child,
  html[lang="zh-CN"] .class-top-card .page-actions > span { grid-column: 1 / -1; }
  html[lang="zh-CN"] .class-top-card .page-actions .button {
    width: 100%;
    min-width: 0;
    padding-inline: 7px;
    gap: 5px;
    font-size: 12px;
    white-space: nowrap;
  }
  html[lang="zh-CN"] .class-top-card .page-actions .button svg { width: 16px; height: 16px; flex: 0 0 16px; }
  html[lang="zh-CN"] .class-top-card .page-actions > span { margin-left: 0 !important; justify-self: start; }
  html, body, #app, .workspace, .page, .card { max-width: 100%; }
}
