/* Shared visual system for the Archive web interface. */
:root {
  --bg: #f6f4f8;
  --text: #241f2e;
  --muted: #625a70;
  --line: #e8e2ed;
  --soft: #f1edf5;
  --soft-2: #faf8fc;
  --ink: #302048;
  --tint: #f0e9fa;
  --focus: #7250be;
  --surface: rgba(255, 255, 255, .88);
  --shadow: 0 12px 38px rgba(52, 35, 72, .08);
  --ui-font: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  color: var(--text);
  background: radial-gradient(ellipse at 6% 0, #efe8f7, transparent 40rem), var(--bg);
  font-family: var(--ui-font);
  -webkit-font-smoothing: antialiased;
}
body :is(h1, h2, h3, h4, .hero-title, .sheet-title, .item-name-overlay) {
  font-family: var(--ui-font);
  letter-spacing: -.035em;
  overflow-wrap: anywhere;
}
body :is(button, a, input, textarea, select, summary):focus-visible {
  outline: 3px solid var(--focus) !important;
  outline-offset: 3px;
}

.archive-identity { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; color: var(--ink); }
.archive-mark { display: block; width: 40px; height: auto; flex: 0 0 auto; }

/* Account selection, unlock and maintenance */
body.archive-choosing {
  background: radial-gradient(ellipse at 15% 10%, #e7dcf9, transparent 57%),
              radial-gradient(ellipse at 92% 82%, #f7dfda, transparent 56%), #f6f2fa;
}
body:is(.archive-choosing, .archive-gated) .topbar { display: none !important; }
body.archive-choosing #app { min-height: calc(100svh - 72px); padding-bottom: 0; }
body.archive-choosing .page-shell { max-width: none; padding: 0 !important; }
.archive-chooser {
  position: relative;
  display: grid;
  place-items: center;
  min-height: calc(100svh - 72px);
  padding: max(28px, env(safe-area-inset-top)) 16px 24px;
}
.chooser-panel {
  width: min(100%, 506px);
  padding: clamp(20px, 5vw, 36px);
  border-radius: 36px;
  border: 1px solid #fff;
  background: rgba(255, 255, 255, .61);
  -webkit-backdrop-filter: blur(22px);
  backdrop-filter: blur(22px);
  box-shadow: 0 24px 80px #59427b20, inset 0 1px 0 #fff;
}
.chooser-heading { margin: 0 0 22px; }
.chooser-heading .archive-identity { font-size: 14px; }
.chooser-heading h1 { color: var(--ink); font-size: clamp(42px, 8vw, 60px); line-height: 1; margin: 20px 0 8px; }
.chooser-heading p { margin: 0; color: var(--muted); font-size: 16px; }
.chooser-accounts { display: grid; }
.archive-chooser .chooser-account {
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 12px;
  min-height: 64px;
  padding: 9px 4px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  box-shadow: none;
  transform: none;
}
.archive-chooser .chooser-account + .chooser-account { border-top: 1px solid #59427b25; }
@media (hover: hover) {
  .archive-chooser .chooser-account:not(:disabled):hover .kp-profile-name { color: #65468a; }
}
.archive-chooser .kp-profile-avatar-wrap { width: 44px; height: 44px; padding: 2px; background: #ded3ec; }
.archive-chooser .kp-profile-avatar-wrap.is-auto-login { background: #9ecdb8; }
.archive-chooser .kp-profile-avatar-fallback { color: #4f3870; background: #eee6f8; }
.archive-chooser .kp-profile-avatar-fallback .material-symbols-rounded { color: inherit; font-size: 22px; }
.archive-chooser :is(.kp-profile-name, .kp-profile-status) { display: block; }
.archive-chooser .kp-profile-name { color: var(--text); font-size: 15px; font-weight: 750; line-height: 1.2; }
.archive-chooser .kp-profile-status { color: var(--muted); font-size: 12px; margin: 3px 0 0; }
.archive-chooser .kp-profile-status::after { color: inherit; }
.archive-chooser .kp-maintenance-pill { color: #874529; background: #fbe9db; padding: 5px 8px; }
.chooser-chevron { color: #746789; font-size: 21px; }
.archive-chooser .kp-login-enter-overlay { background: #f8f4fcce; }
body .maintenance-shell { border-radius: 30px; background: var(--surface); border: 1px solid #fff; box-shadow: var(--shadow); padding: clamp(22px, 5vw, 48px); }
body.archive-gated .maintenance-shell { margin-top: clamp(12px, 8vh, 88px); }
body .maintenance-text { color: var(--muted); }

/* Catalog, navigation and item details */
body .topbar {
  background: #fcfaffdc !important;
  -webkit-backdrop-filter: saturate(1.25) blur(22px);
  backdrop-filter: saturate(1.25) blur(22px);
  border-bottom: 1px solid var(--line) !important;
  padding-inline: max(20px, calc((100% - 1260px) / 2));
  gap: 24px;
}
.archive-topbar-brand { flex-shrink: 0; white-space: nowrap; }
body .topbar .archive-topbar-actions { min-width: 0; }
body .topbar .search-wrap { background: #f1edf5 !important; border-color: transparent !important; box-shadow: none !important; }
body .topbar .search-wrap:focus-within { border-color: #c1acdc !important; background: #fff !important; }
body .page-shell { max-width: 1308px; }
#adminView h1 { margin: 0; color: var(--ink); font-size: clamp(32px, 6vw, 54px); line-height: 1.08; }
#archiveView .catalog-section { padding-top: clamp(10px, 2vw, 28px); }

#itemsGrid.archive-grid { gap: clamp(12px, 2vw, 22px); }
body #itemsGrid .card {
  border: 1px solid var(--line);
  border-radius: 25px;
  background: #fff;
  box-shadow: 0 6px 22px #3926500b;
  display: flex;
  flex-direction: column;
}
#itemsGrid .card-media { aspect-ratio: 4 / 3; background: linear-gradient(145deg, #f1e9fa, #ede8f2 60%, #eadedc); }
#itemsGrid .photo-overlay { padding: 32px 16px 14px; background: linear-gradient(transparent, #1f1628da); }
#itemsGrid .item-name-overlay { font-size: clamp(16px, 2vw, 22px); font-weight: 750; letter-spacing: -.02em; }
#itemsGrid .section-badge {
  background: #faf6fdeb;
  color: var(--ink);
  border: 1px solid #ffffff91;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  font-weight: 700;
}
#itemsGrid .card-body { padding: clamp(12px, 2vw, 18px); }
#itemsGrid .info-row { color: var(--muted); }
#itemsGrid .info-row .material-symbols-rounded { color: #765e92; }
body .no-photo { align-content: center; gap: 5px; color: #6b587c; }
.no-photo .material-symbols-rounded { font-size: 29px; }
body #itemsGrid .no-photo { padding-bottom: 45px; }
#itemsGrid .empty-state { grid-column: 1 / -1; display: grid; justify-items: center; gap: 8px; padding: 56px 16px; border: 1px dashed #d6cadf; border-radius: 24px; background: #ffffff79; color: var(--muted); text-align: center; }
#itemsGrid .empty-state strong { color: var(--ink); }
#itemsGrid .empty-state .material-symbols-rounded { color: #795f9b; font-size: 32px; }

body :is(.sheet, .appearance-settings) { background: var(--surface); border: 1px solid var(--line); border-radius: 26px; box-shadow: var(--shadow); padding: clamp(16px, 3vw, 30px); }
body .sheet-title { font-weight: 760; color: var(--ink); }
#itemView .sheet-title { font-size: clamp(27px, 5vw, 44px); line-height: 1.1; }
#itemView .gallery-main { background: #eee7f3; border-radius: 22px; }
#itemView .thumb-btn { border-radius: 14px; border-color: var(--line); }
body .detail-list { border-radius: 18px; padding: 4px 14px; background: #f7f3fa; }
body .detail-line { border-color: var(--line); }
body .detail-line > :last-child { min-width: 0; overflow-wrap: anywhere; }
body :is(.logger-item, .panel-item) { border-color: var(--line); }
body .logger-item { padding: 16px; border-radius: 18px; background: var(--surface); }
#adminView .panel-grid > * { min-width: 0; }
#adminView .appearance-settings h3 { margin: 16px 0; }
body .section-kicker { color: #705687; letter-spacing: .06em; }

/* Controls, forms, notifications and overlays */
body :is(.btn, .icon-btn, .tab-chip, .inventory-badge) { transition: background-color .18s, box-shadow .18s, filter .18s; }
body :is(.btn-soft, .icon-btn, .inventory-badge) { background: #f3eef7; color: var(--ink); border-color: var(--line); }
body .btn-danger { background: #f9e9ed; color: #8a2944; border-color: #f1dce4; }
body :is(.btn, .icon-btn):disabled { opacity: .58; cursor: not-allowed; }
body .modal .modal-card:not(.item-form-modal-card) {
  background: #fffffff2 !important;
  border: 1px solid #fff !important;
  border-radius: 27px !important;
  box-shadow: 0 22px 78px #29203237 !important;
}
body .modal .modal-backdrop {
  background: #2d1a4057;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
body .modal .modal-card .form-actions .btn:first-child {
  animation: none !important;
  box-shadow: none !important;
}
body .modal .modal-card .form-actions .btn:first-child::before,
body .modal .modal-card .form-actions .btn:first-child::after { display: none !important; }
body .item-form-modal .modal-card.item-form-modal-card { background: var(--bg) !important; }
body .item-form-modal :is(.sheet-head, .form-actions) { background: #fcf9fff2 !important; }
body :is(.field, .modal-card) :is(input:not([type="checkbox"], [type="radio"], [type="color"]), textarea, select) {
  background: #fcfafe !important;
  border-color: #dfd7e8 !important;
  color: var(--text) !important;
}
body :is(.field, .modal-card) :is(input, textarea)::placeholder { color: #70677d; }
body .photo-tile { border-radius: 16px; background-color: var(--soft); }
body .qr-box { border: 1px solid var(--line); border-radius: 18px; }
body .toast { border-radius: 18px; box-shadow: 0 10px 36px #2e213b40; }
body .org-modal .org-items { border-radius: 16px; }
body .org-modal :is(.org-choice, .org-row, section) { border-color: var(--line); }
body #organizerNotice { background: var(--tint); color: var(--ink); border-color: var(--line); }

body .legal-footer { gap: 2px 8px; padding: 12px 16px max(14px, env(safe-area-inset-bottom)); }
body .legal-footer a { padding: 6px 9px; border-radius: 10px; }
body .legal-footer a:hover { background: #ffffff94; }
@media (max-width: 720px) {
  body .topbar { gap: 10px; }
  .archive-topbar-brand .archive-mark { width: 34px; }
  .archive-chooser {
    align-items: start;
    padding: max(32px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 24px max(20px, env(safe-area-inset-left));
  }
  .chooser-panel {
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .archive-chooser .chooser-account { min-height: 68px; }
  #itemsGrid .section-badge { padding: 4px 7px; top: 7px; right: 7px; font-size: 10px; }
  #itemsGrid .photo-overlay { padding: 23px 9px 9px; }
  body .maintenance-shell { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  body :is(.chooser-account, .card, .btn, .icon-btn, .tab-chip) { transition: none !important; }
}

#itemsGrid .card-media { flex: 0 0 auto; }
#itemsGrid .card-body { flex: 1; grid-template-rows: repeat(4, auto) 1fr; align-items: start; }
#itemsGrid .card-condition { padding: 5px 9px; font-size: 12px; }
#itemsGrid .card-footer {
  align-self: end;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
  margin-top: 3px;
}
#itemsGrid .card-footer .inventory-badge {
  min-height: 44px;
  min-width: 0;
  max-width: 100%;
  border-radius: 12px;
  gap: 7px;
  padding: 6px 10px;
  font-size: 13px;
  overflow-wrap: anywhere;
}
#itemsGrid .card-footer .material-symbols-rounded { font-size: 19px; }
#itemsGrid .card-footer .card-actions { gap: 5px; margin-left: auto; }
#itemsGrid .card-footer .icon-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 12px;
  background: #fff;
}
#itemsGrid .card-footer .card-delete { color: #8a2944; }
@media (max-width: 500px) {
  #itemsGrid.archive-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (hover: hover) {
  body :is(.card, .btn, .icon-btn, .tab-chip, .thumb-btn, .inventory-badge, .chooser-account):hover:not(:active) {
    transform: none !important;
    filter: none !important;
  }
  body :is(.card-media, .gallery-main, .thumb-btn) img:hover { transform: none !important; }
  body :is(.btn-soft, .icon-btn, .inventory-badge):not(:disabled):hover,
  #itemsGrid .card-footer .icon-btn:hover { background: #eee7f4; }
  #itemsGrid .card-footer .card-delete:hover { background: #fbecf0; }
}
#itemsGrid .card-media-empty .photo-overlay { background: transparent; color: var(--ink); }
#itemsGrid .card-media-empty .item-name-overlay { text-shadow: none; }
body .item-form-modal .item-form-modal-card > :is(.sheet-head, #itemForm) { max-width: 1060px; margin-inline: auto !important; }
body .item-form-modal .item-form-modal-card { height: 100dvh !important; }
#itemsGrid .card-footer button.inventory-badge {
  min-height: 44px !important;
  border-radius: 12px !important;
  padding: 6px 10px !important;
  font-size: 13px !important;
}
#itemView .gallery-main:has(.no-photo) { aspect-ratio: auto; min-height: 150px; }
#itemView .gallery-main:has(.no-photo) .no-photo { min-height: 150px; }
@media (max-width: 720px) {
  body.archive-toolbar-mode .topbar #searchInput { padding-right: 3px !important; }
  #itemsGrid .card-media { border-radius: 14px; }
}

body .topbar #openProfileBtn .profile-control-icon {
  display: inline-grid !important;
  place-items: center;
  font-size: 22px;
}
body .topbar #openProfileBtn { width: 44px; padding: 0; flex-shrink: 0; }
body .topbar #openProfileBtn .profile-control-icon { font-style: normal; }
#itemsGrid .card-footer .card-actions { margin-top: 0 !important; }
.archive-chooser .kp-profile-avatar-wrap {
  width: 44px !important;
  height: 44px !important;
  min-width: 44px !important;
  min-height: 44px !important;
  max-width: 44px !important;
  max-height: 44px !important;
}
.archive-chooser .kp-profile-name { font-size: 15px !important; }
.archive-chooser .kp-profile-status { font-size: 12px !important; }
.chooser-heading h1 { font-size: clamp(42px, 8vw, 54px); }
