:root {
  --ink: #17231d;
  --muted: #68736d;
  --line: #dfe6e1;
  --surface: #ffffff;
  --wash: #f2f6f3;
  --green: #176b49;
  --green-dark: #0d4f35;
  --lime: #d8f36a;
  --danger: #a43c3c;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", sans-serif;
  color: var(--ink);
  background: var(--wash);
}

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

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 250px 1fr; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 250px; z-index: 10;
  display: flex; flex-direction: column; padding: 30px 20px;
  color: #f5fff9; background: var(--ink);
}
.brand { display: flex; gap: 13px; align-items: center; color: inherit; text-decoration: none; padding: 0 8px; }
.brand-mark, .auth-mark {
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px;
  color: var(--ink); background: var(--lime); font-weight: 800; font-family: Georgia, serif;
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 18px; letter-spacing: -.02em; }
.brand small { margin-top: 2px; color: #9aaba1; font-size: 12px; }
.navigation { display: grid; gap: 7px; margin-top: 54px; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 13px 14px; border-radius: 11px; color: #aebcb4; text-decoration: none; font-size: 14px; }
.nav-item:hover, .nav-item.active { color: #fff; background: rgba(255,255,255,.09); }
.nav-icon { width: 22px; color: var(--lime); font-size: 18px; text-align: center; }
.sidebar-footer { margin-top: auto; display: flex; gap: 9px; align-items: center; padding: 0 10px; color: #91a198; font-size: 12px; }
.environment-dot { width: 7px; height: 7px; border-radius: 50%; background: #6fe5a6; box-shadow: 0 0 0 4px rgba(111,229,166,.12); }

.main-content { grid-column: 2; min-width: 0; padding: 38px clamp(24px, 4vw, 68px) 56px; }
.topbar { display: flex; justify-content: space-between; align-items: end; margin-bottom: 36px; }
.eyebrow { margin: 0 0 7px; color: var(--green); font-size: 10px; font-weight: 800; letter-spacing: .16em; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-family: Georgia, "Songti SC", serif; font-size: clamp(30px, 4vw, 46px); font-weight: 500; letter-spacing: -.04em; }
.quiet-button, .pagination-button { border: 1px solid var(--line); color: var(--ink); background: var(--surface); border-radius: 10px; padding: 10px 14px; cursor: pointer; }
.quiet-button:hover, .pagination-button:hover:not(:disabled) { border-color: #aebdb4; }

.intro-panel { position: relative; overflow: hidden; min-height: 260px; display: flex; align-items: center; padding: clamp(28px, 5vw, 62px); border-radius: 24px; color: white; background: linear-gradient(125deg, #15392b, #1b7652); }
.intro-panel h2 { max-width: 590px; margin: 21px 0 12px; font-family: Georgia, "Songti SC", serif; font-size: clamp(30px, 4.3vw, 54px); font-weight: 500; line-height: 1.08; }
.intro-panel p { max-width: 570px; margin-bottom: 0; color: #c6ded1; line-height: 1.7; }
.status-pill { padding: 6px 10px; border: 1px solid rgba(216,243,106,.35); border-radius: 999px; color: var(--lime); font-size: 11px; font-weight: 700; }
.intro-orbit { position: absolute; right: -40px; width: 270px; height: 270px; border: 1px solid rgba(255,255,255,.14); border-radius: 50%; display: grid; place-items: center; }
.intro-orbit::before { content: ""; position: absolute; width: 170px; height: 170px; border: 1px solid rgba(255,255,255,.13); border-radius: 50%; }
.intro-orbit span { z-index: 1; font-size: 52px; color: var(--lime); }
.section-heading { display: flex; justify-content: space-between; align-items: end; margin: 44px 0 18px; }
.section-heading h2 { margin: 0; font-size: 22px; }
.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; }
.module-card { min-height: 190px; display: grid; grid-template-columns: auto 1fr auto; gap: 20px; align-items: start; padding: 27px; border: 1px solid var(--line); border-radius: 18px; color: inherit; background: var(--surface); text-decoration: none; transition: transform .18s ease, box-shadow .18s ease; }
.module-card:hover { transform: translateY(-3px); box-shadow: 0 16px 36px rgba(23,35,29,.08); }
.module-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; color: var(--green-dark); background: var(--lime); font-size: 20px; }
.module-kicker { margin-bottom: 12px; color: var(--green); font-size: 10px; font-weight: 800; letter-spacing: .13em; }
.module-card h3 { margin-bottom: 9px; font-size: 20px; }
.module-card p:last-child { color: var(--muted); font-size: 13px; line-height: 1.65; }
.module-arrow { align-self: end; color: var(--green); font-size: 22px; }
.identity-panel { margin-top: 28px; padding: 24px 26px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); }
.identity-panel h2 { margin-bottom: 7px; font-size: 19px; }
.identity-panel > div:first-child > p:last-child { margin-bottom: 0; color: var(--muted); font-size: 12px; }
.identity-value-row { display: flex; align-items: center; gap: 12px; margin-top: 18px; }
.identity-value-row code { min-width: 0; flex: 1; overflow: hidden; padding: 12px 14px; border-radius: 10px; color: var(--green-dark); background: var(--wash); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.identity-value-row button:disabled { opacity: .45; cursor: not-allowed; }
.identity-error { margin: 12px 0 0; color: var(--danger); font-size: 12px; }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 24px; }
.toolbar p { margin: 0; color: var(--muted); font-size: 14px; }
.filter-controls { display: flex; align-items: end; justify-content: flex-end; gap: 10px; }
.filter-field { display: grid; gap: 5px; }
.filter-field span { color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.filter-field select {
  min-width: 132px; height: 40px; padding: 0 34px 0 12px; border: 1px solid var(--line);
  border-radius: 10px; outline: none; color: var(--ink); background: var(--surface); cursor: pointer;
}
.filter-field select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23,107,73,.1); }
.view-switcher { display: flex; height: 40px; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.view-option { border: 0; border-radius: 7px; padding: 0 11px; color: var(--muted); background: transparent; cursor: pointer; font-size: 12px; }
.view-option:hover { color: var(--ink); }
.view-option.active { color: white; background: var(--green); }
.primary-button { border: 0; border-radius: 10px; padding: 11px 17px; color: white; background: var(--green); cursor: pointer; font-weight: 700; }
.primary-button:hover { background: var(--green-dark); }
.migration-button { border: 1px solid var(--green); border-radius: 10px; padding: 10px 16px; color: var(--green-dark); background: #eff8f2; cursor: pointer; font-weight: 700; }
.migration-button:hover:not(:disabled) { color: white; background: var(--green); }
.migration-button:disabled { opacity: .48; cursor: not-allowed; }
.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 17px; }
.image-card { overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.image-frame { aspect-ratio: 4 / 3; position: relative; display: grid; place-items: center; background: #e8eeea; overflow: hidden; }
.image-frame img { width: 100%; height: 100%; object-fit: cover; opacity: 0; cursor: zoom-in; transition: opacity .2s ease; }
.image-frame img:focus-visible { outline: 3px solid var(--lime); outline-offset: -3px; }
.image-frame img.loaded { opacity: 1; }
.image-placeholder { position: absolute; color: #91a097; font-size: 12px; }
.image-badges { position: absolute; top: 10px; left: 10px; display: flex; gap: 6px; }
.badge { padding: 5px 8px; border-radius: 999px; color: white; background: rgba(23,35,29,.75); backdrop-filter: blur(8px); font-size: 10px; font-weight: 700; }
.badge.loved { color: var(--ink); background: var(--lime); }
.badge.synced { color: #093e29; background: #aee6c6; }
.image-info { padding: 15px; }
.record-name { margin-bottom: 11px; overflow: hidden; color: var(--ink); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.metadata { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.metadata div { min-width: 0; }
.metadata dt { color: #8a958f; font-size: 9px; letter-spacing: .06em; text-transform: uppercase; }
.metadata dd { margin: 3px 0 0; overflow: hidden; color: #3c4942; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.image-grid.list-mode { grid-template-columns: 1fr; }
.image-grid.list-mode .image-card { display: grid; grid-template-columns: 190px minmax(0, 1fr); }
.image-grid.list-mode .image-frame { height: 132px; aspect-ratio: auto; }
.image-grid.list-mode .image-info { display: grid; grid-template-columns: minmax(220px, .8fr) minmax(0, 2fr); gap: 26px; align-items: center; padding: 20px 24px; }
.image-grid.list-mode .record-name { margin: 0; }
.image-grid.list-mode .metadata { grid-template-columns: repeat(3, minmax(90px, 1fr)); }
.collections-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 20px; }
.collection-card { overflow: hidden; border: 1px solid var(--line); border-radius: 18px; color: inherit; background: var(--surface); cursor: pointer; transition: transform .18s ease, box-shadow .18s ease; }
.collection-card:hover { transform: translateY(-3px); box-shadow: 0 16px 36px rgba(23,35,29,.08); }
.collection-card:focus-visible { outline: 3px solid rgba(23,107,73,.3); outline-offset: 3px; }
.collection-cover { position: relative; aspect-ratio: 16 / 10; display: grid; place-items: center; overflow: hidden; color: #849189; background: linear-gradient(135deg, #dfeae3, #f2f6f3); }
.collection-cover::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 55%, rgba(9,28,18,.42)); pointer-events: none; }
.collection-cover img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .2s ease; }
.collection-cover img.loaded { opacity: 1; }
.collection-count { position: absolute; right: 12px; bottom: 11px; z-index: 1; padding: 5px 8px; border-radius: 999px; color: white; background: rgba(14,36,24,.7); backdrop-filter: blur(7px); font-size: 10px; font-weight: 700; }
.collection-card-body { padding: 18px; }
.collection-card-body h3 { margin-bottom: 13px; overflow: hidden; font-size: 18px; text-overflow: ellipsis; white-space: nowrap; }
.collection-card-meta { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 11px; }
.collection-card-record { margin: 12px 0 0; overflow: hidden; color: #87928c; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.collection-card-badges, .detail-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.collection-label { padding: 5px 8px; border-radius: 999px; color: var(--green-dark); background: #e4eee8; font-size: 9px; font-weight: 800; }
.collection-label.recommended { background: var(--lime); }
.back-button { margin-bottom: 22px; border: 0; padding: 0; color: var(--green); background: transparent; cursor: pointer; font-weight: 700; }
.collection-detail-header { padding: clamp(24px, 4vw, 42px); border-radius: 20px; color: white; background: linear-gradient(125deg, #15392b, #1b7652); }
.collection-detail-header h2 { margin: 0 0 12px; font-family: Georgia, "Songti SC", serif; font-size: clamp(28px, 4vw, 44px); font-weight: 500; }
.collection-detail-header p { margin: 0; color: #bdd2c6; font-size: 12px; }
.collection-detail-header .collection-label { color: var(--lime); background: rgba(255,255,255,.12); }
.collection-detail-header .collection-label.recommended { color: var(--ink); background: var(--lime); }
.detail-tabs { display: flex; gap: 26px; margin: 30px 0 22px; border-bottom: 1px solid var(--line); }
.detail-tab { position: relative; border: 0; padding: 0 2px 13px; color: var(--muted); background: transparent; cursor: pointer; font-size: 14px; font-weight: 700; }
.detail-tab.active { color: var(--ink); }
.detail-tab.active::after { content: ""; position: absolute; right: 0; bottom: -1px; left: 0; height: 2px; background: var(--green); }
.collection-images-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.empty-state.compact { min-height: 260px; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 18px; margin-top: 32px; color: var(--muted); font-size: 13px; }
.pagination-button:disabled { opacity: .42; cursor: not-allowed; }
.loading-state, .empty-state { min-height: 360px; display: grid; place-items: center; align-content: center; color: var(--muted); text-align: center; }
.spinner { width: 28px; height: 28px; border: 3px solid #d5ded8; border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; }
.loading-state p { margin: 13px 0 0; }
.empty-state span { color: var(--green); font-size: 34px; }
.empty-state h3 { margin: 12px 0 5px; color: var(--ink); }
.empty-state p { font-size: 13px; }
.error-banner { margin-bottom: 20px; padding: 13px 16px; border: 1px solid #edcaca; border-radius: 11px; color: var(--danger); background: #fff3f2; font-size: 13px; }
.success-banner { margin-bottom: 20px; padding: 13px 16px; border: 1px solid #b8dbc7; border-radius: 11px; color: var(--green-dark); background: #edf8f1; font-size: 13px; }

.auth-dialog { width: min(430px, calc(100vw - 32px)); padding: 0; border: 0; border-radius: 22px; box-shadow: 0 28px 90px rgba(12,30,21,.25); }
.auth-dialog::backdrop { background: rgba(10,26,18,.72); backdrop-filter: blur(5px); }
.auth-dialog form { padding: 38px; }
.auth-dialog .auth-mark { margin-bottom: 28px; background: var(--green); color: white; }
.auth-dialog h2 { margin-bottom: 10px; font-family: Georgia, "Songti SC", serif; font-size: 30px; font-weight: 500; }
.auth-dialog form > p:not(.eyebrow):not(.form-error) { color: var(--muted); font-size: 13px; line-height: 1.65; }
.auth-dialog label { display: block; margin: 24px 0 7px; font-size: 12px; font-weight: 700; }
.auth-dialog input { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 12px 13px; outline: none; }
.auth-dialog input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23,107,73,.12); }
.full-width { width: 100%; margin-top: 18px; }
.form-error { margin: 9px 0 -5px; color: var(--danger); font-size: 12px; }

.image-viewer { width: 100vw; max-width: none; height: 100vh; max-height: none; margin: 0; padding: 0; border: 0; color: white; background: transparent; }
.image-viewer::backdrop { background: rgba(5, 12, 8, .9); backdrop-filter: blur(10px); }
.viewer-content { position: relative; width: 100%; height: 100%; display: grid; grid-template-rows: 1fr auto; place-items: center; padding: 32px; pointer-events: none; }
.viewer-content > img { min-width: 0; min-height: 0; max-width: 100%; max-height: calc(100vh - 110px); object-fit: contain; border-radius: 8px; box-shadow: 0 20px 70px rgba(0,0,0,.35); pointer-events: auto; }
.viewer-close { position: fixed; top: 22px; right: 24px; z-index: 1; width: 42px; height: 42px; border: 1px solid rgba(255,255,255,.22); border-radius: 50%; color: white; background: rgba(12,24,17,.62); cursor: pointer; font-size: 28px; line-height: 1; pointer-events: auto; }
.viewer-close:hover { background: rgba(255,255,255,.16); }
.viewer-footer { width: 100%; display: flex; justify-content: space-between; gap: 20px; padding-top: 16px; color: #b9c7bf; font-size: 11px; }
.viewer-footer span:first-child { overflow: hidden; color: white; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; text-overflow: ellipsis; white-space: nowrap; }

@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 780px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: auto; height: auto; padding: 18px; }
  .navigation { display: flex; margin-top: 18px; overflow-x: auto; }
  .nav-item { white-space: nowrap; }
  .sidebar-footer { display: none; }
  .main-content { padding: 26px 18px 44px; }
  .topbar { align-items: center; }
  .intro-orbit { opacity: .45; }
  .image-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .collections-grid, .collection-images-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .image-grid.list-mode .image-card { grid-template-columns: 150px minmax(0, 1fr); }
  .image-grid.list-mode .image-info { display: block; padding: 14px 16px; }
  .image-grid.list-mode .record-name { margin-bottom: 11px; }
  .image-grid.list-mode .metadata { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
  .topbar h1 { font-size: 29px; }
  .quiet-button { font-size: 12px; }
  .intro-panel { min-height: 230px; }
  .intro-orbit { right: -120px; }
  .module-grid { grid-template-columns: 1fr; }
  .module-card { grid-template-columns: auto 1fr; }
  .module-arrow { display: none; }
  .identity-value-row { align-items: stretch; flex-direction: column; }
  .image-grid { grid-template-columns: 1fr; }
  .collections-grid { grid-template-columns: 1fr; }
  .toolbar { align-items: start; flex-direction: column; }
  .filter-controls { width: 100%; flex-wrap: wrap; justify-content: start; }
  .filter-field { flex: 1; }
  .filter-field select { width: 100%; }
  .view-switcher { flex: 1 0 100%; }
  .view-option { flex: 1; }
  .image-grid.list-mode .image-card { grid-template-columns: 110px minmax(0, 1fr); }
  .image-grid.list-mode .image-frame { height: 100%; min-height: 132px; }
  .viewer-content { padding: 18px; }
  .viewer-footer { justify-content: center; }
  .viewer-footer span:last-child { display: none; }
}
