:root {
  --bg: #F5F6F8; --card: #FFFFFF; --line: #E3E6EB; --line2: #EEF0F3;
  --ink: #16181D; --ink2: #3B4048; --mute: #575D68;
  --blue: #2457C5; --blue-dark: #163E94; --blue-soft: #DCE6FA; --chip: #EEF1F5;
  --green: #1F6B36; --green-soft: #E8F4EC; --red: #B3261E;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: Inter, system-ui, sans-serif; font-size: 15px; -webkit-tap-highlight-color: transparent; }
a { color: var(--blue); } a:hover { color: var(--blue-dark); }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid #C3CBD8; background: #fff; font-weight: 600; color: var(--blue); text-decoration: none; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.danger { color: var(--red); border-color: #E3B7B3; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { width: 44px; height: 44px; border: 0; background: transparent; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; color: var(--ink2); }
.icon-btn:hover { background: var(--chip); }

/* layout */
.top { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top-in { padding: 12px 24px; display: flex; gap: 12px 24px; align-items: center; }
.brand { display: flex; gap: 10px; align-items: center; font-size: 20px; font-weight: 700; width: 216px; text-decoration: none; color: var(--ink); }
.brand svg { color: var(--blue); width: 28px; height: 28px; }
.search { flex: 1 1 320px; max-width: 640px; display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 18px; border-radius: 24px; background: var(--chip); color: var(--mute); }
.search input { border: 0; outline: 0; background: transparent; font-size: 16px; width: 100%; color: var(--ink); }
.top .right { margin-left: auto; display: flex; gap: 4px; }
.wrap { display: flex; gap: 24px; padding: 20px 24px 48px; align-items: flex-start; }
.side { flex: 0 0 236px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 92px; }
.side .new { align-self: flex-start; min-height: 52px; padding: 0 22px; margin-bottom: 12px; border: 0; border-radius: 16px; background: #fff; box-shadow: 0 1px 4px rgba(22,24,29,.15); font-weight: 600; display: inline-flex; align-items: center; gap: 10px; }
.side .new svg { color: var(--blue); }
.nav { display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 0 16px; border-radius: 20px; color: var(--ink); text-decoration: none; }
.nav:hover { background: #E9ECF1; color: var(--ink); }
.nav.on { background: var(--blue-soft); color: var(--blue-dark); font-weight: 600; }
.nav .n { margin-left: auto; font-size: 13px; color: var(--mute); font-weight: 400; }
.space { margin-top: 20px; padding: 16px; display: flex; flex-direction: column; gap: 8px; border-top: 1px solid var(--line); }
.space .who { font-size: 13px; color: var(--mute); line-height: 1.7; }
main.content { flex: 1 1 auto; min-width: 0; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 24px; display: flex; flex-direction: column; gap: 20px; }
h1 { margin: 0; font-size: 22px; font-weight: 600; }
h2 { margin: 0; font-size: 16px; font-weight: 600; color: var(--ink2); }
.muted { color: var(--mute); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }

/* storage bar */
.bar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: #E2E6EC; }
.bar.big { height: 14px; border-radius: 7px; }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }

/* folders */
.folders { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.folder { display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 0 14px; border-radius: 12px; background: #F1F4F8; text-decoration: none; color: var(--ink); }
.folder:hover { background: #E7ECF3; color: var(--ink); }
.folder b { display: block; font-weight: 600; }
.folder small { color: var(--mute); font-size: 12px; }

/* table */
.tablebox { overflow-x: auto; }
table { width: 100%; min-width: 560px; border-collapse: collapse; }
th { text-align: left; color: var(--mute); font-size: 13px; font-weight: 500; padding: 10px 8px; border-bottom: 1px solid var(--line); }
td { padding: 8px; border-bottom: 1px solid var(--line2); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.name { display: flex; align-items: center; gap: 10px; min-height: 44px; }
td.name button { border: 0; background: none; padding: 0; text-align: left; color: var(--ink); }
td.name button:hover { text-decoration: underline; }
.mini { width: 36px; height: 36px; border-radius: 6px; object-fit: cover; background: #EEF1F5; flex: none; display: flex; align-items: center; justify-content: center; color: var(--mute); }
.empty { padding: 40px 16px; text-align: center; color: var(--mute); line-height: 1.6; }

/* photos */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 3px; }
.tile { position: relative; aspect-ratio: 1; background: #EEF1F5; border: 0; padding: 0; overflow: hidden; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .tag { position: absolute; left: 5px; top: 5px; font-size: 10px; font-weight: 700; color: #fff; background: var(--green); padding: 1px 5px; border-radius: 4px; }
.tile .vid { position: absolute; right: 5px; bottom: 5px; color: #fff; background: rgba(22,24,29,.6); border-radius: 4px; padding: 2px 4px; display: flex; }
.tile .vid svg { width: 14px; height: 14px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { min-height: 36px; padding: 0 14px; border: 1px solid #D5D9E0; border-radius: 18px; background: #fff; font-size: 14px; }
.chip.on { background: var(--blue-soft); color: var(--blue-dark); border-color: var(--blue-soft); font-weight: 600; }

/* cards */
.card { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.acct { display: flex; flex-direction: column; gap: 8px; padding: 16px 0; border-bottom: 1px solid var(--line2); }
.acct:last-child { border-bottom: 0; }
.acct .top-line { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.acct .name { font-weight: 600; font-size: 16px; display: flex; gap: 8px; align-items: center; }
.add { display: flex; align-items: center; gap: 16px; min-height: 72px; padding: 0 20px; border: 1px solid #D5D9E0; border-radius: 12px; background: #fff; width: 100%; text-align: left; }
.add:hover { border-color: var(--blue); }
.add .logo { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex: none; }
.add b { display: block; font-size: 17px; }
.add small { color: var(--mute); font-size: 14px; }
.warn { background: #FDF1E7; color: #7A3A12; border-radius: 12px; padding: 12px 14px; line-height: 1.5; }
.ok { background: var(--green-soft); color: #174F28; border-radius: 14px; padding: 12px 14px; display: flex; gap: 12px; align-items: center; }
.ok small { display: block; color: #2D5A3A; }

/* switches */
.set { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line2); }
.set:last-child { border-bottom: 0; }
.set .t { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.set .t span { font-size: 16px; font-weight: 500; }
.set .t small { font-size: 13px; color: var(--mute); }
.switch { width: 52px; height: 32px; border: 0; border-radius: 16px; background: #C9CED6; padding: 4px; display: flex; flex: none; }
.switch::after { content: ""; width: 24px; height: 24px; border-radius: 12px; background: #fff; }
.switch[aria-pressed="true"] { background: var(--blue); justify-content: flex-end; }

/* login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login form { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 32px; width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 14px; font-weight: 600; }
.field input { min-height: 48px; padding: 0 14px; border: 1px solid #C9CED6; border-radius: 10px; font-size: 16px; }
.err { color: var(--red); font-size: 14px; min-height: 1em; }

/* viewer + toasts */
.viewer { position: fixed; inset: 0; background: rgba(10,12,16,.92); z-index: 50; display: flex; flex-direction: column; }
.viewer .bar2 { display: flex; align-items: center; gap: 8px; padding: 10px 12px; color: #fff; }
.viewer .bar2 .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer .bar2 .icon-btn, .viewer .bar2 a.icon-btn { color: #fff; }
.viewer .bar2 .icon-btn:hover { background: rgba(255,255,255,.12); }
.viewer .stage { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; padding: 8px; }
.viewer img, .viewer video { max-width: 100%; max-height: 100%; }
.viewer .doc { background: #fff; border-radius: 14px; padding: 28px; max-width: 380px; text-align: center; display: flex; flex-direction: column; gap: 14px; align-items: center; }
#toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 60; width: min(420px, calc(100% - 32px)); }
.toast { background: #22252B; color: #fff; padding: 12px 16px; border-radius: 12px; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.toast .p { height: 4px; background: rgba(255,255,255,.2); border-radius: 2px; margin-top: 8px; overflow: hidden; }
.toast .p div { height: 100%; background: #86A8EE; }
.menu { position: absolute; right: 0; top: 44px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(22,24,29,.15); padding: 6px; z-index: 20; min-width: 180px; display: flex; flex-direction: column; }
.menu button, .menu a { border: 0; background: none; text-align: left; min-height: 40px; padding: 0 12px; border-radius: 8px; color: var(--ink); text-decoration: none; display: flex; align-items: center; }
.menu button:hover, .menu a:hover { background: var(--chip); }
.menu .del { color: var(--red); }
.rel { position: relative; }

/* phone */
.tabs { display: none; }
.fab { display: none; }
@media (max-width: 760px) {
  .top-in { padding: 12px 16px; flex-wrap: wrap; }
  .brand { width: auto; font-size: 18px; }
  .search { order: 3; flex: 1 1 100%; max-width: none; }
  .side { display: none; }
  .wrap { padding: 12px 12px 110px; }
  main.content { padding: 16px; border-radius: 14px; gap: 16px; }
  main.content.photos { padding: 12px 0; border: 0; background: transparent; }
  main.content.photos .pad { padding: 0 4px; }
  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 2px; }
  .folders { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .phone-hide { display: none !important; }
  .tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--line); padding: 8px 4px calc(10px + env(safe-area-inset-bottom)); z-index: 10; }
  .tabs a { display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 48px; text-decoration: none; color: var(--ink2); font-size: 12px; }
  .tabs a span { padding: 4px 18px; border-radius: 14px; display: flex; }
  .tabs a.on { color: var(--blue); font-weight: 600; }
  .tabs a.on span { background: var(--blue-soft); }
  .fab { display: flex; position: fixed; right: 16px; bottom: 92px; width: 56px; height: 56px; border: 0; border-radius: 16px; background: var(--blue); color: #fff; align-items: center; justify-content: center; box-shadow: 0 6px 16px rgba(36,87,197,.35); z-index: 11; }
  #toasts { bottom: 160px; }
  table { min-width: 0; }
  .col-folder, .col-acct, .col-date { display: none; }
}
@media (min-width: 761px) { .phone-only { display: none !important; } }
