/* Contact Sheet — owner dashboard. Apple-style tool: system type, one tint, grouped forms.
   The Index mark + Sora wordmark is the only brand voice; galleries are shown like albums in Photos. */

:root {
  --bg: #f2f2f7;
  --grouped: #ffffff;
  --label: #1d1d1f;
  --secondary: #6e6e73;
  --sep: rgba(60, 60, 67, .16);
  --fill: rgba(118, 118, 128, .12);
  --fill-strong: rgba(118, 118, 128, .2);
  --tint: #007aff;
  --tint-soft: rgba(0, 122, 255, .1);
  --green: #248a3d;
  --orange: #c93400;
  --red: #d70015;
  --tile: #e5e5ea;
  --ease: cubic-bezier(.16, 1, .3, 1);
  color-scheme: light dark;
  accent-color: var(--tint);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --grouped: #1c1c1e;
    --label: #f5f5f7;
    --secondary: #a1a1a6;
    --sep: rgba(84, 84, 88, .6);
    --fill: rgba(118, 118, 128, .24);
    --fill-strong: rgba(118, 118, 128, .36);
    --tint: #0a84ff;
    --tint-soft: rgba(10, 132, 255, .18);
    --green: #30d158;
    --orange: #ff9f0a;
    --red: #ff453a;
    --tile: #2c2c2e;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scrollbar-color: var(--fill-strong) transparent; }
body {
  margin: 0; background: var(--bg); color: var(--label);
  font: 400 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", system-ui, sans-serif;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  caret-color: var(--tint);
}
::selection { background: var(--tint-soft); }
a { color: var(--tint); text-decoration: none; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--tint) 55%, transparent); outline-offset: 2px; border-radius: 8px; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

/* Index identity: 3x3 contact-sheet grid with one frame picked in yellow + Sora wordmark */
.brand { margin: 0; display: inline-flex; align-items: center; gap: 10px; font: 600 19px/1.02 "Sora", -apple-system, system-ui, sans-serif; letter-spacing: -0.03em; white-space: nowrap; color: var(--label); }
.brand img { display: block; border-radius: 7px; }
.brand-stack { flex-direction: column; gap: 16px; font-size: 34px; text-align: center; }
.brand-stack img { border-radius: 14px; box-shadow: 0 8px 24px rgba(22,24,29,.18); }
@media (prefers-color-scheme: dark) { .brand img { box-shadow: 0 0 0 1px rgba(255,255,255,.12); } }
.secondary { color: var(--secondary); }
.error { color: var(--red); margin: 0; font-size: 13px; min-height: 18px; }

/* Buttons */
.btn {
  font: inherit; font-size: 15px; font-weight: 600; letter-spacing: -0.01em;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 44px; padding: 0 20px; border: 0; border-radius: 12px; cursor: pointer; white-space: nowrap;
  transition: background-color .2s, opacity .2s, transform .15s var(--ease);
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.filled { background: var(--tint); color: #fff; }
.btn.filled:hover:not(:disabled) { background: color-mix(in srgb, var(--tint) 88%, #000); }
.btn.tinted { background: var(--tint-soft); color: var(--tint); }
.btn.tinted:hover { background: color-mix(in srgb, var(--tint) 16%, transparent); }
.btn.plain { background: transparent; color: var(--tint); padding: 0 12px; font-weight: 400; }
.btn.plain:hover { background: var(--fill); }
.btn svg { width: 18px; height: 18px; }

/* Grouped form rows */
.group { background: var(--grouped); border-radius: 12px; overflow: hidden; }
.field {
  position: relative; display: grid; grid-template-columns: 112px 1fr; align-items: center; gap: 12px;
  min-height: 48px; padding: 4px 16px;
}
.field + .field::before { content: ''; position: absolute; top: 0; left: 16px; right: 0; height: .5px; background: var(--sep); }
.field > span { font-size: 15px; }
.field input {
  font: inherit; color: var(--label); background: transparent; border: 0; padding: 10px 0; width: 100%; min-width: 0;
}
.field input::placeholder { color: color-mix(in srgb, var(--secondary) 75%, transparent); }
.field input:focus { outline: none; }
.field:focus-within { background: color-mix(in srgb, var(--tint) 4%, var(--grouped)); }
.footnote { margin: 8px 16px 0; font-size: 13px; color: var(--secondary); }

/* ---------------------------------------------------------------- sign in */

.login { min-height: 100svh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(380px, 100%); display: grid; gap: 14px; }
.login-card .brand { justify-self: center; margin-bottom: 6px; }
.login-card .lede { margin: -4px 0 18px; text-align: center; color: var(--secondary); }
.login-card .field { grid-template-columns: 1fr; }
.login-card .btn { width: 100%; }
.login-card .error { text-align: center; }

/* ---------------------------------------------------------------- app */

.app { max-width: 1120px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 40px) 96px; }
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 64px; margin: 0 calc(-1 * clamp(16px, 4vw, 40px)); padding: 10px clamp(16px, 4vw, 40px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.8) blur(20px); -webkit-backdrop-filter: saturate(1.8) blur(20px);
}
.top-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.status { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--secondary); padding: 0 6px; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.status.warn { color: var(--orange); }
.status.warn .dot { background: var(--orange); }

.notice {
  display: flex; align-items: center; gap: 10px;
  margin: 12px 0 0; padding: 12px 16px; border-radius: 12px; background: var(--grouped); font-size: 15px;
}
.notice svg { width: 20px; height: 20px; }
.notice[data-kind="ok"] svg { color: var(--green); }
.notice[data-kind="warn"] svg { color: var(--orange); }

.status-who { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 600px) {
  .brand { font-size: 17px; }
  .status-who, #dbx-off { display: none; }
  .top-right { flex-wrap: nowrap; gap: 0; }
}


/* ---------------------------------------------------------------- library */

.new-btn { padding: 0 16px 0 13px; margin-left: 4px; }
.new-btn svg { width: 17px; height: 17px; stroke-width: 2.2; }
.display-title { margin: 0; font-size: clamp(30px, 4.2vw, 40px); line-height: 1.05; font-weight: 700; letter-spacing: -0.025em; }
.lib-head { display: grid; gap: 6px; margin: 36px 0 26px; }
.lib-head .secondary { margin: 0; font-size: 15px; font-variant-numeric: tabular-nums; min-height: 1.45em; }

.albums { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 40px 28px; }
.album { display: grid; gap: 12px; min-width: 0; align-content: start; }

/* Cover + two frames beside it: a small contact sheet, echoing the Index mark. */
.album-art {
  display: grid; grid-template-columns: 2fr 1fr; grid-template-rows: 1fr 1fr; gap: 3px;
  aspect-ratio: 3 / 2; border-radius: 14px; overflow: hidden; background: var(--tile);
  box-shadow: 0 1px 2px rgba(0,0,0,.06), 0 0 0 .5px rgba(0,0,0,.06);
  transition: transform .5s var(--ease), box-shadow .5s var(--ease);
}
.album-art:not(.mosaic) { grid-template-columns: 1fr; }
.album-art img, .art-empty { width: 100%; height: 100%; object-fit: cover; display: block; min-height: 0; background: var(--tile); }
.art-main { grid-row: 1 / -1; }
@media (hover: hover) {
  .album-art:hover { transform: translateY(-3px); box-shadow: 0 14px 30px -12px rgba(0,0,0,.35), 0 0 0 .5px rgba(0,0,0,.06); }
}
@media (prefers-color-scheme: dark) { .album-art { box-shadow: 0 0 0 .5px rgba(255,255,255,.08); } }

.album-meta { display: flex; align-items: flex-start; gap: 8px; min-width: 0; }
.album-text { min-width: 0; flex: 1; padding-top: 2px; }
.album-title { margin: 0; font-size: 17px; font-weight: 600; line-height: 1.3; letter-spacing: -0.015em; color: var(--label); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.album-title a { color: inherit; }
.album-sub { margin: 3px 0 0; font-size: 13px; color: var(--secondary); font-variant-numeric: tabular-nums; }
.album .error { margin-top: 4px; }

.album-actions { position: relative; display: flex; gap: 2px; margin-right: -8px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent; cursor: pointer;
  display: grid; place-items: center; color: var(--secondary); position: relative;
  transition: background-color .2s, color .2s;
}
.icon-btn::after { content: ''; position: absolute; inset: -2px; }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn:hover, .icon-btn[aria-expanded="true"] { background: var(--fill); color: var(--label); }
.icon-btn.done { color: var(--green); }

/* Overflow menu (Apple-style context menu) */
.menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 10; min-width: 240px; padding: 6px;
  background: color-mix(in srgb, var(--grouped) 92%, transparent);
  backdrop-filter: blur(24px) saturate(1.8); -webkit-backdrop-filter: blur(24px) saturate(1.8);
  border-radius: 14px; box-shadow: 0 18px 50px -12px rgba(0,0,0,.35), 0 0 0 .5px var(--sep);
  transform-origin: top right; animation: menu-in .18s var(--ease);
}
@keyframes menu-in { from { opacity: 0; transform: scale(.96); } }
.menu a, .menu button {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 0 12px;
  border: 0; border-radius: 9px; background: none; font: inherit; font-size: 15px; color: var(--label); text-align: left; cursor: pointer;
}
.menu svg { width: 19px; height: 19px; color: var(--secondary); }
.menu a:hover, .menu button:hover, .menu :focus-visible { background: var(--fill); outline: none; }
.menu .danger, .menu .danger svg { color: var(--red); }
.menu .danger { margin-top: 6px; position: relative; }
.menu .danger::before { content: ''; position: absolute; top: -3.5px; left: 12px; right: 12px; height: .5px; background: var(--sep); }

.empty {
  grid-column: 1 / -1; display: grid; justify-items: center; gap: 6px;
  padding: 64px 24px 72px; border-radius: 18px; background: var(--grouped); text-align: center; color: var(--secondary);
}
.empty-mark { width: 56px; height: 56px; border-radius: 14px; background: #16181d; color: #4a4e58; display: grid; place-items: center; margin-bottom: 10px; }
.empty-mark svg { width: 34px; height: 34px; stroke: none; fill: currentColor; }
.empty-mark svg rect[fill] { fill: #ffcc00; }
.empty b { color: var(--label); font-size: 20px; font-weight: 600; letter-spacing: -0.015em; }
.empty p { margin: 0 0 14px; max-width: 38ch; text-wrap: pretty; }
.skeleton { aspect-ratio: 3 / 2; border-radius: 14px; background: var(--tile); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } * { transition-duration: .01ms !important; animation-duration: .01ms !important; } }

/* ---------------------------------------------------------------- new gallery sheet */

.sheet {
  width: min(520px, calc(100% - 32px)); max-height: calc(100svh - 48px); padding: 0; border: 0; border-radius: 18px;
  background: var(--bg); color: var(--label);
  box-shadow: 0 30px 80px -20px rgba(0,0,0,.45), 0 0 0 .5px var(--sep);
}
.sheet::backdrop { background: rgba(0,0,0,.32); backdrop-filter: blur(2px); }
.sheet[open] { animation: sheet-in .35s var(--ease); }
@keyframes sheet-in { from { opacity: 0; transform: translateY(16px) scale(.98); } }
.sheet-body { display: grid; gap: 14px; padding: 8px 20px 20px; }
.sheet-nav { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; margin: 0 -12px; min-height: 52px; }
.sheet-nav .btn.plain { justify-self: start; }
.sheet-nav h2 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -0.015em; }
.sheet-note { margin: 0; padding: 12px 14px; border-radius: 12px; background: var(--tint-soft); color: var(--label); font-size: 14px; }
.field-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.btn.small { min-height: 30px; padding: 0 12px; border-radius: 15px; font-size: 13px; }
.sheet .footnote { margin: -6px 16px 0; }
.sheet .footnote b { color: var(--label); font-weight: 600; }
.btn.wide { width: 100%; margin-top: 4px; }
.sheet .error:empty { display: none; }

.howto { border-radius: 12px; background: var(--grouped); }
.howto summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between;
  min-height: 48px; padding: 0 16px; font-size: 15px; color: var(--tint);
}
.howto summary::-webkit-details-marker { display: none; }
.howto summary::after { content: ''; width: 8px; height: 8px; border: solid var(--secondary); border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-2px, -2px); transition: transform .25s var(--ease); }
.howto[open] summary::after { transform: rotate(-135deg) translate(-2px, -2px); }
.howto .create-steps { padding: 4px 16px 4px; }
.howto .tip { margin: 12px 16px 16px; font-size: 13px; color: var(--secondary); }
.howto .tip b { color: var(--label); font-weight: 600; }
.create-steps { margin: 0; list-style: none; display: grid; gap: 10px; counter-reset: step; font-size: 14px; }
.create-steps li { display: grid; grid-template-columns: 26px 1fr; gap: 10px; color: var(--secondary); counter-increment: step; }
.create-steps li::before {
  content: counter(step); width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; font-size: 12px; font-weight: 600; background: var(--fill); color: var(--label);
}
.create-steps b { color: var(--label); font-weight: 600; }

@media (max-width: 600px) {
  /* A bottom sheet on phones */
  .sheet { width: 100%; max-width: none; margin: auto 0 0; border-radius: 18px 18px 0 0; max-height: 92svh; padding-bottom: env(safe-area-inset-bottom); }
  .sheet[open] { animation: sheet-up .4s var(--ease); }
  @keyframes sheet-up { from { transform: translateY(100%); } }
  .new-btn { width: 44px; padding: 0; border-radius: 50%; }
  .new-btn span { display: none; }
  #logout { padding: 0 10px; }
  .lib-head { margin: 20px 0 20px; }
  .albums { gap: 32px; }
}
@media (max-width: 480px) { .field { grid-template-columns: 1fr; gap: 0; padding-top: 10px; } .field > span:first-child { font-size: 13px; color: var(--secondary); } }
