/* Hemdrive — one stylesheet, light and dark. Tokens follow docs/koncept.html. */

:root {
  --bg: #f4f3ef;
  --panel: #ffffff;
  --ink: #1c1d21;
  --muted: #6b6d75;
  --line: #e3e1da;
  --accent: #2f6fde;
  --accent-ink: #ffffff;
  --accent-soft: #e6eefc;
  --ok: #1f8a5b;
  --warn: #b4581d;
  --danger: #c0392b;
  --folder: #e9a23b;
  --shadow: 0 6px 18px rgba(20, 24, 32, 0.12);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121316; --panel: #1b1d22; --ink: #ececef; --muted: #9a9ca5; --line: #2b2e35;
    --accent: #5b8ff0; --accent-soft: #1d2a44; --folder: #e0a246; --danger: #e05545; --ok: #3fb37f;
    --shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121316; --panel: #1b1d22; --ink: #ececef; --muted: #9a9ca5; --line: #2b2e35;
  --accent: #5b8ff0; --accent-soft: #1d2a44; --folder: #e0a246; --danger: #e05545; --ok: #3fb37f;
  --shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
.app { max-width: 560px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; position: relative; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ── Inloggning ─────────────────────────────────────────────────────── */
.auth { padding: max(48px, env(safe-area-inset-top)) 22px 28px; display: flex; flex-direction: column; flex: 1; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 22px; }
.logo-mark { width: 38px; height: 38px; border-radius: 11px; background: var(--accent); display: grid; place-items: center; color: #fff; }
.auth h1 { font-size: 22px; margin: 28px 0 4px; }
.field { margin-top: 16px; display: block; }
.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.input {
  width: 100%; border: 1px solid var(--line); background: var(--panel); border-radius: 12px;
  padding: 13px 14px; font-size: 16px; outline: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.btn {
  display: block; width: 100%; margin-top: 18px; border: 0; border-radius: 12px; padding: 13px;
  background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: 15px;
}
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.ghost { background: var(--panel); color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: var(--panel); color: var(--danger); border: 1px solid var(--line); }
.linkbtn { background: none; border: 0; color: var(--accent); padding: 8px 0; font-weight: 600; }
.linkbtn:disabled { color: var(--muted); font-weight: 400; }
.error { color: var(--danger); font-size: 13px; margin-top: 12px; min-height: 18px; }
.info { color: var(--muted); font-size: 12px; margin-top: 12px; text-align: center; }
.secure { margin-top: auto; padding-top: 24px; display: flex; gap: 6px; align-items: center; justify-content: center; font-size: 12px; color: var(--ok); }
.code { display: flex; gap: 8px; justify-content: center; margin-top: 22px; }
.code input {
  width: 46px; height: 56px; text-align: center; font-size: 24px; font-weight: 600;
  border: 1px solid var(--line); background: var(--panel); border-radius: 12px; outline: none; padding: 0;
}
.code input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.check { display: flex; gap: 10px; align-items: center; margin-top: 16px; font-size: 14px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }

/* ── Ram: topp, innehåll, flikar ────────────────────────────────────── */
.top { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: max(12px, env(safe-area-inset-top)) 16px 6px; }
.top .title { font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 8px; min-width: 0; }
.top .title .logo-mark { width: 28px; height: 28px; border-radius: 8px; }
.back { background: none; border: 0; color: var(--accent); font-weight: 600; padding: 6px 0; display: flex; align-items: center; gap: 2px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; border: 0; }
.main { flex: 1; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
.crumbs { padding: 0 16px; font-size: 13px; color: var(--muted); white-space: nowrap; overflow-x: auto; scrollbar-width: none; }
.crumbs button { background: none; border: 0; padding: 2px 0; color: var(--muted); }
.crumbs button:last-child { color: var(--ink); font-weight: 600; }
.crumbs .sep { margin: 0 5px; }
.search { margin: 10px 16px 6px; position: relative; }
.search input { padding-left: 36px; font-size: 15px; padding-top: 10px; padding-bottom: 10px; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 560px;
  display: flex; justify-content: space-around; border-top: 1px solid var(--line); background: var(--panel);
  padding: 8px 0 max(10px, env(safe-area-inset-bottom)); z-index: 5;
}
.tabbar button { background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; color: var(--muted); padding: 2px 16px; }
.tabbar button.on { color: var(--accent); font-weight: 600; }

/* ── Listor ─────────────────────────────────────────────────────────── */
.list { margin-top: 4px; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; }
.row:active { background: var(--accent-soft); }
.rowmain { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; background: none; border: 0; padding: 0; text-align: left; }
.mt10 { margin-top: 10px; }
.item.block { display: block; }
.between { display: flex; justify-content: space-between; gap: 10px; }
.row .name { font-size: 15px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .meta { font-size: 12px; color: var(--muted); }
.row .grow { flex: 1; min-width: 0; }
.ico { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.ico.folder { background: color-mix(in srgb, var(--folder) 22%, transparent); color: var(--folder); }
.ico.inbox { background: var(--accent-soft); color: var(--accent); }
.ico.file { background: var(--accent-soft); color: var(--accent); }
.ico.img { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.ico.trash { background: var(--line); color: var(--muted); }
.more { background: none; border: 0; color: var(--muted); padding: 8px; font-size: 20px; line-height: 1; }
.empty { text-align: center; color: var(--muted); padding: 48px 24px; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; padding: 6px 3px; }
.grid button { aspect-ratio: 1; border: 0; padding: 0; background: var(--line); overflow: hidden; border-radius: 4px; }
.grid img { width: 100%; height: 100%; object-fit: cover; display: block; }

.fab {
  position: fixed; right: max(18px, calc(50% - 262px)); bottom: calc(86px + env(safe-area-inset-bottom));
  width: 56px; height: 56px; border-radius: 18px; border: 0; background: var(--accent); color: #fff;
  display: grid; place-items: center; box-shadow: 0 8px 20px rgba(47, 111, 222, 0.4); z-index: 6;
}

/* ── Förhandsvisning ───────────────────────────────────────────────── */
.preview { padding: 6px 16px 16px; }
.preview h2 { font-size: 16px; margin: 0 0 10px; word-break: break-word; }
.preview .stage { border-radius: 14px; overflow: hidden; background: var(--panel); border: 1px solid var(--line); display: grid; place-items: center; min-height: 220px; }
.preview img, .preview video { max-width: 100%; max-height: 65vh; display: block; }
.preview .fallback { padding: 40px 20px; text-align: center; color: var(--muted); }
.actions { display: flex; gap: 10px; margin-top: 12px; }
.actions .btn { margin-top: 0; }
.actions a.btn { text-align: center; text-decoration: none; }

/* ── Ark (bottom sheet) ─────────────────────────────────────────────── */
.dim { position: fixed; inset: 0; background: rgba(10, 12, 16, 0.45); z-index: 20; }
.sheet {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: 100%; max-width: 560px; z-index: 21;
  background: var(--panel); border-radius: 22px 22px 0 0; padding: 10px 18px max(20px, env(safe-area-inset-bottom));
  max-height: 85vh; overflow-y: auto; box-shadow: var(--shadow);
}
.grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 14px; }
.sheet h3 { margin: 0 0 2px; font-size: 17px; word-break: break-word; }
.sheet .sub { font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.sheet .opt { display: flex; align-items: center; gap: 12px; width: 100%; padding: 13px 4px; background: none; border: 0; border-bottom: 1px solid var(--line); text-align: left; font-size: 15px; }
.sheet .opt:last-of-type { border-bottom: 0; }
.sheet .opt.danger { color: var(--danger); font-weight: 600; }
.choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.choices button { border: 1px solid var(--line); background: var(--bg); border-radius: 12px; padding: 12px 4px; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; }

.xfer { padding: 10px 0; border-bottom: 1px solid var(--line); }
.xfer:last-child { border-bottom: 0; }
.xfer .head { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.xfer .head .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.xfer .state { font-size: 11px; font-weight: 600; flex: none; }
.xfer .state.ok { color: var(--ok); }
.xfer .state.paused { color: var(--warn); }
.xfer .state.err { color: var(--danger); }
.xfer .note { font-size: 11px; color: var(--muted); margin-top: 3px; }
.bar { height: 5px; border-radius: 3px; background: var(--line); margin-top: 6px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }
.bar.paused i { background: var(--warn); }

/* ── Banderoll och notis ───────────────────────────────────────────── */
.banner {
  margin: 8px 12px 0; padding: 10px 12px; border-radius: 12px; font-size: 13px;
  background: color-mix(in srgb, var(--warn) 15%, var(--panel)); border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent);
}
.banner b { color: var(--warn); display: block; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); top: max(14px, env(safe-area-inset-top)); z-index: 30; box-shadow: var(--shadow);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: calc(100% - 32px);
}
.xfer-pill {
  position: fixed; left: 16px; bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 6;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; font-size: 13px; box-shadow: var(--shadow);
}

/* ── Konto ─────────────────────────────────────────────────────────── */
.page-title { padding: max(14px, env(safe-area-inset-top)) 16px 4px; font-weight: 700; font-size: 22px; margin: 0; }
.acct { display: flex; align-items: center; gap: 12px; padding: 8px 16px 6px; }
.acct .avatar { width: 48px; height: 48px; font-size: 20px; }
.sec { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding: 16px 16px 6px; }
.group { margin: 0 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 14px; width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; }
.item:last-child { border-bottom: 0; }
.item small { display: block; font-size: 12px; color: var(--muted); }
.item .danger, .item.danger { color: var(--danger); font-weight: 600; }
.item.center { justify-content: center; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); display: inline-block; margin-right: 6px; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; flex: none; }
.seg button { border: 0; background: none; padding: 6px 10px; font-size: 12px; color: var(--muted); }
.seg button.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.switch { position: relative; width: 44px; height: 26px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch i { position: absolute; inset: 0; border-radius: 13px; background: var(--line); transition: background 0.15s; pointer-events: none; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: left 0.15s; }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { left: 21px; }
.switch input:focus-visible + i { box-shadow: 0 0 0 3px var(--accent-soft); }
.meter { height: 7px; border-radius: 4px; background: var(--line); margin-top: 8px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--accent); }
.version { text-align: center; font-size: 11px; color: var(--muted); padding: 14px 0 4px; }

.spinner { width: 26px; height: 26px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; margin: 40px auto; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.5s; } .bar i { transition: none; } }

/* ── Rörelse ───────────────────────────────────────────────────────────
   Korta, mjuka övergångar. Allt stängs av med "minska rörelse" i mobilen. */
:root { --ease: cubic-bezier(0.2, 0.8, 0.2, 1); }
body { transition: background-color 0.3s ease, color 0.3s ease; }

@keyframes view-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes row-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pop-in { 0% { opacity: 0; transform: scale(0.6); } 70% { transform: scale(1.06); } 100% { opacity: 1; transform: scale(1); } }
@keyframes sheet-in { from { transform: translate(-50%, 100%); } to { transform: translate(-50%, 0); } }
@keyframes sheet-out { from { transform: translate(-50%, 0); } to { transform: translate(-50%, 100%); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes drop-in { from { opacity: 0; transform: translate(-50%, -14px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes slide-down { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes shake { 0%, 100% { transform: none; } 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes done-flash { 0% { background: color-mix(in srgb, var(--ok) 22%, transparent); } 100% { background: transparent; } }
@keyframes tab-bounce { 0% { transform: scale(1); } 40% { transform: scale(1.18); } 100% { transform: scale(1); } }

.auth, .main, .page-title { animation: view-in 0.32s var(--ease) backwards; }
.auth .logo-mark { animation: float 3.2s ease-in-out infinite; }
.list > .row, .list > div.row, .group, .xfer { animation: row-in 0.3s var(--ease) backwards; }
.list > :nth-child(2) { animation-delay: 0.03s; } .list > :nth-child(3) { animation-delay: 0.06s; }
.list > :nth-child(4) { animation-delay: 0.09s; } .list > :nth-child(5) { animation-delay: 0.12s; }
.list > :nth-child(6) { animation-delay: 0.15s; } .list > :nth-child(7) { animation-delay: 0.18s; }
.list > :nth-child(8) { animation-delay: 0.21s; } .list > :nth-child(n+9) { animation-delay: 0.24s; }
.main > .group:nth-of-type(2) { animation-delay: 0.05s; } .main > .group:nth-of-type(3) { animation-delay: 0.1s; }
.main > .group:nth-of-type(4) { animation-delay: 0.15s; } .main > .group:nth-of-type(n+5) { animation-delay: 0.2s; }

.grid img { opacity: 0; transform: scale(1.04); transition: opacity 0.35s ease, transform 0.5s var(--ease); }
.grid img.loaded { opacity: 1; transform: none; }
.grid button { transition: transform 0.15s var(--ease); }
.grid button:active { transform: scale(0.95); }
.preview .stage img, .preview .stage video { animation: fade-in 0.4s ease both; }

.fab { animation: pop-in 0.42s var(--ease) 0.15s backwards; transition: transform 0.15s var(--ease), box-shadow 0.15s; }
.fab:active { transform: scale(0.9) rotate(90deg); }
.btn, .row, .item, .choices button, .opt, .back, .linkbtn { transition: transform 0.12s var(--ease), background-color 0.15s, opacity 0.15s; }
.btn:active:not(:disabled), .choices button:active { transform: scale(0.97); }
.row:active, .item:active { transform: scale(0.99); }
.tabbar button.on svg { animation: tab-bounce 0.35s var(--ease); }

.dim { animation: fade-in 0.22s ease both; }
.sheet { animation: sheet-in 0.32s var(--ease) both; }
.dim.closing { animation: fade-out 0.2s ease both; }
.sheet.closing { animation: sheet-out 0.22s ease-in both; }
.toast { animation: drop-in 0.28s var(--ease) both; }
.toast.closing { animation: fade-out 0.25s ease both; }
.banner:not(.hidden) { animation: slide-down 0.3s var(--ease) both; }
.xfer-pill:not(.hidden) { animation: pop-in 0.35s var(--ease) both; }
.code.shake { animation: shake 0.4s ease; }
.code input { transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s; }
.code input:focus { transform: translateY(-2px); }
.xfer.just-done { animation: done-flash 1.2s ease; }
.switch i, .switch i::after { transition: background 0.2s ease, left 0.2s var(--ease); }
.seg button { transition: background-color 0.2s ease, color 0.2s ease; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; animation-delay: 0s !important; transition-duration: 0.01ms !important; }
}
