/* PhotoDrop — modern, sharp edges everywhere (owner spec: sharp-edge buttons,
   frames, cards). Light paper background, ink borders, one blue accent. */

:root {
  --ink: #0b1220;
  --paper: #f2f4f7;
  --card: #ffffff;
  --line: #0b1220;
  --muted: #5b6472;
  --accent: #1f5eff;
  --accent-ink: #ffffff;
  --danger: #c81e1e;
  --ok: #0e7a3d;
  --shadow: 0 2px 0 0 var(--ink);
}

* { box-sizing: border-box; border-radius: 0 !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--paper);
  color: var(--ink);
}
.hidden { display: none !important; }

/* ---------- buttons & fields (sharp system) ---------- */
.btn {
  font: inherit;
  font-weight: 700;
  border: 2px solid var(--line);
  background: var(--card);
  color: var(--ink);
  padding: 12px 18px;
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: transform 0.05s ease, box-shadow 0.05s ease;
  box-shadow: var(--shadow);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn:active { transform: translate(1px, 1px); box-shadow: none; }
.btn-solid { background: var(--ink); color: #fff; }
.btn-accent { background: var(--accent); border-color: var(--ink); color: var(--accent-ink); }
.btn-ghost { background: transparent; box-shadow: none; border-color: var(--line); }
.btn-outline { background: var(--card); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 13px; }

.field { display: block; margin-bottom: 14px; }
.field-label {
  display: block;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 6px;
  color: var(--muted);
}
.field input, .field select {
  font: inherit;
  width: 100%;
  padding: 12px 12px;
  border: 2px solid var(--line);
  background: var(--card);
  color: var(--ink);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}
.field input:focus, .field select:focus { box-shadow: 3px 3px 0 0 var(--accent); }

/* ---------- cards ---------- */
.card {
  background: var(--card);
  border: 2px solid var(--line);
  box-shadow: 4px 4px 0 0 rgba(11, 18, 32, 0.9);
  padding: 22px;
}

/* ---------- login ---------- */
.login-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    repeating-linear-gradient(45deg, rgba(11,18,32,0.045) 0 2px, transparent 2px 14px),
    var(--paper);
}
.login-card { width: 100%; max-width: 380px; }
.login-mark {
  display: block;
  margin-left: auto;
  margin-right: auto;
  width: 140px; height: 140px;
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  margin-bottom: 14px;
}
.login-title {
  margin: 0 0 4px;
  font-size: 32px;
  font-weight: 900;
  letter-spacing: -0.01em;
  background: linear-gradient(135deg, #00c6ff 0%, #2563eb 55%, #7c3aed 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}
.login-sub { margin: 0 0 20px; color: var(--muted); font-size: 14px; }
.form-error {
  border: 2px solid var(--danger);
  background: #fdecec;
  color: var(--danger);
  padding: 9px 10px;
  font-size: 13.5px;
  font-weight: 600;
  margin: 0 0 14px;
}

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--ink);
  color: #fff;
  border-bottom: 3px solid var(--accent);
}
.topbar-inner {
  max-width: 1100px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 28px; height: 28px; padding: 0; background: transparent; border: none; }
.brand-name {
  font-weight: 800;
  letter-spacing: 0.02em;
  font-size: 17px;
  text-transform: none;
  background: linear-gradient(135deg, #00c6ff 0%, #2563eb 55%, #7c3aed 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
}
.topbar-right { display: flex; align-items: center; gap: 10px; }
.who { font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; color: #9aa4b2; }
#logout-btn { border-color: #fff; color: #fff; }

/* ---------- gallery ---------- */
.gallery-wrap { max-width: 1100px; margin: 0 auto; padding: 18px 16px 110px; }
.gallery-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.gallery-title { margin: 0; font-size: 21px; letter-spacing: -0.01em; }
.count-chip {
  border: 2px solid var(--line);
  background: var(--card);
  font-size: 12px;
  font-weight: 800;
  padding: 3px 9px;
  letter-spacing: 0.06em;
}
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 960px) { .grid { grid-template-columns: repeat(4, 1fr); } }

.photo-card {
  border: 2px solid var(--line);
  background: var(--card);
  box-shadow: 4px 4px 0 0 rgba(11,18,32,0.9);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.06s ease;
}
.photo-card:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 0 rgba(11,18,32,0.9); }
.photo-thumb { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; background: #dfe3e9; }
.photo-meta { padding: 9px 10px 10px; }
.photo-note {
  margin: 0 0 5px;
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  min-height: 1.3em;
}
.photo-info { margin: 0; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.07em; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- empty state ---------- */
.empty { text-align: center; padding: 60px 20px; }
.empty-box {
  width: 84px; height: 84px;
  margin: 0 auto 18px;
  border: 3px dashed var(--ink);
  background: var(--card);
}
.empty-title { font-size: 19px; font-weight: 800; margin: 0 0 6px; }
.empty-sub { color: var(--muted); margin: 0; line-height: 1.55; }

/* ---------- upload bar ---------- */
.uploadbar {
  position: fixed; left: 0; right: 0; bottom: 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--paper) 70%, rgba(242,244,247,0));
  display: flex; justify-content: center;
  z-index: 15;
}
.btn-add {
  font-size: 17px;
  padding: 15px 34px;
  background: var(--accent);
  color: #fff;
}

/* ---------- overlays ---------- */
.overlay {
  position: fixed; inset: 0;
  background: rgba(11, 18, 32, 0.66);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  z-index: 40;
}
.upload-card { width: 100%; max-width: 380px; }
.upload-title { margin: 0 0 14px; font-size: 17px; }
.upload-list { display: flex; flex-direction: column; gap: 10px; }
.upload-row { border: 2px solid var(--line); padding: 9px 10px; background: var(--paper); }
.upload-row-top { display: flex; justify-content: space-between; font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.upload-row .bar { height: 10px; border: 2px solid var(--line); background: var(--card); }
.upload-row .bar > i { display: block; height: 100%; background: var(--accent); width: 0%; }
.upload-row.done .bar > i { background: var(--ok); }
.upload-row.fail .bar > i { background: var(--danger); }

/* ---------- detail viewer ---------- */
.detail {
  position: fixed; inset: 0;
  background: var(--ink);
  z-index: 50;
  display: flex; flex-direction: column;
}
.detail-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 2px solid #232c3d;
}
.detail-top .btn-ghost { color: #fff; border-color: #fff; }
.detail-actions { display: flex; gap: 8px; }
.detail-actions .btn-outline { background: transparent; color: #fff; }
.detail-stage {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 8px;
}
.detail-stage img { max-width: 100%; max-height: 100%; object-fit: contain; }
.nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  font-size: 26px; line-height: 1;
  background: rgba(255,255,255,0.92);
  border: 2px solid #fff;
  width: 46px; height: 46px;
  cursor: pointer;
  font-weight: 800;
  color: var(--ink);
}
.nav-prev { left: 10px; }
.nav-next { right: 10px; }
.detail-meta { padding: 12px 16px calc(14px + env(safe-area-inset-bottom)); border-top: 2px solid #232c3d; }
.d-note { margin: 0 0 5px; color: #fff; font-weight: 700; font-size: 15px; }
.d-info { margin: 0; color: #9aa4b2; font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%; bottom: 96px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  border: 2px solid #fff;
  padding: 11px 18px;
  font-weight: 700;
  font-size: 14px;
  z-index: 60;
  box-shadow: 4px 4px 0 0 rgba(0,0,0,0.35);
  max-width: 88vw;
  text-align: center;
}


/* ---------- select mode ---------- */
.head-spacer { flex: 1; }
.select-bar { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
.sel-count {
  border: 2px solid var(--accent);
  color: var(--accent);
  background: var(--card);
  font-size: 12px;
  font-weight: 800;
  padding: 3px 8px;
}
.photo-card.selectable .tick {
  position: absolute;
  top: 8px; left: 8px;
  width: 30px; height: 30px;
  border: 3px solid #fff;
  background: rgba(11, 18, 32, 0.45);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 18px;
  font-weight: 900;
}
.photo-card.selectable { position: relative; }
.photo-card.selectable.selected { outline: 4px solid var(--accent); outline-offset: -4px; }
.photo-card.selectable.selected .tick { background: var(--accent); }

.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }


/* ---------- view switcher ---------- */
.view-switch { display: inline-flex; border: 2px solid var(--line); background: var(--card); }
.vw {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 30px;
  border: 0; background: transparent; cursor: pointer; padding: 0;
}
.vw + .vw { border-left: 2px solid var(--line); }
.vw svg { fill: var(--muted); }
.vw.vw-on { background: var(--ink); }
.vw.vw-on svg { fill: #fff; }

/* ---------- LARGE view: one big photo per row, natural shape ---------- */
#grid.large-view { grid-template-columns: 1fr; }
@media (min-width: 700px) { #grid.large-view { grid-template-columns: 1fr 1fr; } }
#grid.large-view .photo-thumb { aspect-ratio: auto; width: 100%; height: auto; }

/* ---------- LIST view: dense rows, small thumb ---------- */
#grid.list-view { display: flex; flex-direction: column; gap: 10px; }
#grid.list-view .photo-card { display: flex; align-items: stretch; box-shadow: 3px 3px 0 0 rgba(11,18,32,0.9); }
#grid.list-view .photo-thumb { width: 92px; height: 92px; flex: 0 0 92px; aspect-ratio: auto; }
#grid.list-view .photo-meta { flex: 1; padding: 10px 12px; display: flex; flex-direction: column; justify-content: center; }
#grid.list-view .photo-note { -webkit-line-clamp: 3; }
#grid.list-view .tick { top: 6px; left: 6px; }

/* ---------- video cards ---------- */
.video-badge {
  position: absolute; bottom: 8px; right: 8px;
  background: var(--ink); color: #fff;
  border: 2px solid #fff;
  font-size: 11px; font-weight: 800; letter-spacing: 0.08em;
  padding: 2px 7px;
  text-transform: uppercase;
}
.photo-card .photo-thumb.video-thumb { object-fit: cover; background: #101418; }
#d-video { max-width: 100%; max-height: 100%; }

/* ---------- password reveal eye ---------- */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 48px; }
.pw-eye {
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: 44px;
  border: 0;
  background: transparent;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
}
.pw-eye svg { fill: currentColor; }
.pw-eye:active svg { transform: scale(0.92); }
