/* ===== Tokens ===== */

:root {
  --bg: #f2f4f8;
  --glow-1: rgba(70, 110, 255, .14);
  --glow-2: rgba(20, 184, 140, .10);
  --card: #ffffff;
  --card-2: #f7f8fb;
  --text: #121826;
  --muted: #667085;
  --border: #e3e7ef;
  --border-strong: #cdd3df;
  --accent: #2f5bea;
  --accent-hover: #2449c7;
  --accent-soft: #ebf0ff;
  --accent-text: #ffffff;
  --ok: #0f9f55;
  --ok-soft: #e6f7ee;
  --warn: #b26a00;
  --warn-soft: #fff4e0;
  --error: #d92d20;
  --error-soft: #fdecea;
  --track: #e8ecf3;
  --mark: #ffe58a;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 12px 32px -8px rgba(16, 24, 40, .12);
  --radius: 16px;

  /* file-type tiles: background / foreground */
  --t-archive-bg: #fff2df; --t-archive-fg: #b45309;
  --t-database-bg: #e7f0ff; --t-database-fg: #1d4ed8;
  --t-pdf-bg: #fde8e8;     --t-pdf-fg: #c81e1e;
  --t-video-bg: #f3e8ff;   --t-video-fg: #7e22ce;
  --t-audio-bg: #fce7f6;   --t-audio-fg: #be185d;
  --t-image-bg: #e0f6f3;   --t-image-fg: #0f766e;
  --t-doc-bg: #e6efff;     --t-doc-fg: #2b59c3;
  --t-sheet-bg: #e3f6e8;   --t-sheet-fg: #15803d;
  --t-slide-bg: #ffeadd;   --t-slide-fg: #c2410c;
  --t-app-bg: #eceef2;     --t-app-fg: #374151;
  --t-code-bg: #eef2ff;    --t-code-fg: #4338ca;
  --t-other-bg: #eef0f4;   --t-other-fg: #5b6474;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1016;
    --glow-1: rgba(80, 120, 255, .16);
    --glow-2: rgba(20, 184, 140, .08);
    --card: #161a22;
    --card-2: #1b2029;
    --text: #e8eaef;
    --muted: #98a2b3;
    --border: #262c38;
    --border-strong: #353d4c;
    --accent: #5b82ff;
    --accent-hover: #7896ff;
    --accent-soft: #1d2740;
    --ok: #34d17f;
    --ok-soft: #12291d;
    --warn: #f5b546;
    --warn-soft: #2d2412;
    --error: #ff7a70;
    --error-soft: #321a19;
    --track: #252b37;
    --mark: #6b5a12;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 16px 40px -12px rgba(0, 0, 0, .6);

    --t-archive-bg: #33240f; --t-archive-fg: #f6b75a;
    --t-database-bg: #172442; --t-database-fg: #7ea6ff;
    --t-pdf-bg: #3a1718;     --t-pdf-fg: #ff8a85;
    --t-video-bg: #2a1940;   --t-video-fg: #c79bff;
    --t-audio-bg: #3a1630;   --t-audio-fg: #f58ccc;
    --t-image-bg: #0f2f2b;   --t-image-fg: #5fd8c7;
    --t-doc-bg: #182640;     --t-doc-fg: #86a8f5;
    --t-sheet-bg: #133020;   --t-sheet-fg: #6ddc94;
    --t-slide-bg: #3a2115;   --t-slide-fg: #fb9a62;
    --t-app-bg: #252a33;     --t-app-fg: #c3c9d4;
    --t-code-bg: #1e2142;    --t-code-fg: #a5aefc;
    --t-other-bg: #232833;   --t-other-fg: #a8b0be;
  }
}

/* ===== Base ===== */

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(900px 520px at 8% -8%, var(--glow-1), transparent 62%),
    radial-gradient(760px 480px at 105% 5%, var(--glow-2), transparent 58%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 15px/1.5 "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.muted { color: var(--muted); }
.small { font-size: 13px; }

h1 { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: -.01em; }

button, select, input { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ===== Buttons ===== */

button { cursor: pointer; }
button:disabled { cursor: default; }

.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-weight: 600;
  color: var(--accent-text);
  background: var(--accent);
  border: 0;
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .1), inset 0 1px 0 rgba(255, 255, 255, .12);
  transition: background .15s, transform .1s;
}
.primary:hover:not(:disabled) { background: var(--accent-hover); }
.primary:active:not(:disabled) { transform: translateY(1px); }
.primary:disabled { opacity: .7; }
.primary.wide { width: 100%; padding: 12px 20px; }

.ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  font-weight: 550;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, background .15s;
}
.ghost:hover { border-color: var(--border-strong); background: var(--card-2); }
.ghost .icon { width: 17px; height: 17px; }
a.ghost { text-decoration: none; }
a.ghost[hidden] { display: none; }

.link {
  padding: 0;
  font-weight: 550;
  color: var(--accent);
  background: none;
  border: 0;
}
.link:hover { text-decoration: underline; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 10px;
  transition: color .15s, background .15s, border-color .15s;
}
.icon-btn:hover { color: var(--text); background: var(--card-2); }
.icon-btn.bordered { border: 1px solid var(--border); background: var(--card); }
.icon-btn.bordered:hover { border-color: var(--border-strong); }
.icon-btn.spinning .icon { animation: spin .8s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Loading ===== */

.center { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }

.loader {
  width: 34px;
  height: 34px;
  border: 3px solid var(--track);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

/* ===== Password screen ===== */

#login-form { width: 100%; max-width: 380px; }

.login-card {
  padding: 36px 32px 26px;
  text-align: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  animation: rise .35s ease-out;
}
.login-card > p.muted { margin: 6px 0 24px; }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

.lock-badge {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 20px;
  transition: color .3s, background .3s, transform .3s;
}
.lock-badge .icon { width: 30px; height: 30px; }
.lock-badge.opening { color: var(--ok); background: var(--ok-soft); transform: scale(1.08) rotate(-6deg); }

.pw-field { position: relative; }
.pw-field + .pw-field { margin-top: 10px; }

.pw-field input {
  width: 100%;
  height: 48px;
  padding: 0 48px 0 16px;
  font-size: 16px;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.pw-field input:focus { outline: none; background: var(--card); border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.pw-field .icon-btn { position: absolute; top: 5px; right: 5px; }

.caps-hint { margin: 8px 2px 0; font-size: 13px; color: var(--warn); text-align: left; }

#login-btn { margin-top: 16px; }

.btn-spinner { display: none; width: 18px; height: 18px; stroke-width: 2.4; animation: spin .8s linear infinite; }
#login-btn.loading .btn-spinner { display: block; }

.login-msg { min-height: 1.5em; margin: 12px 0 0; font-size: 14px; }
.login-msg.error { color: var(--error); }
.login-msg.info { color: var(--muted); }
.login-msg.ok { color: var(--ok); }

.fine {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 18px 0 0;
  font-size: 13px;
  color: var(--muted);
}
.fine .icon { width: 16px; height: 16px; color: var(--ok); }

.shake { animation: shake .42s cubic-bezier(.36, .07, .19, .97); }
@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(3px); }
  30%, 50%, 70% { transform: translateX(-6px); }
  40%, 60% { transform: translateX(6px); }
}

/* ===== App frame ===== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px max(16px, calc((100% - 820px) / 2));
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; min-width: 0; }
.brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), #6a5cff);
  border-radius: 9px;
  box-shadow: 0 4px 12px -4px var(--accent);
}
.brand-mark .icon { width: 19px; height: 19px; stroke-width: 2; }

.topbar-right { display: flex; align-items: center; gap: 10px; }

.session-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 11px;
  font-size: 13px;
  font-weight: 550;
  color: var(--ok);
  background: var(--ok-soft);
  border-radius: 999px;
  cursor: help;
}

.pulse { position: relative; width: 8px; height: 8px; background: var(--ok); border-radius: 50%; }
.pulse::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--ok);
  border-radius: 50%;
  animation: pulse 2s ease-out infinite;
}
@keyframes pulse { from { transform: scale(1); opacity: .6; } to { transform: scale(2.8); opacity: 0; } }

.shell { max-width: 820px; margin: 0 auto; padding: 24px 16px 96px; }

/* ===== Tabs (segmented, with a sliding highlight) ===== */

.tabs {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  max-width: 500px;
  padding: 4px;
  margin-bottom: 18px;
  background: var(--track);
  border-radius: 12px;
}

.tab-glider {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc((100% - 8px) / 3);
  background: var(--card);
  border-radius: 9px;
  box-shadow: var(--shadow-sm), 0 2px 8px -2px rgba(16, 24, 40, .12);
  transition: transform .25s cubic-bezier(.3, .7, .3, 1);
}
.tabs[data-active="upload"] .tab-glider { transform: translateX(100%); }
.tabs[data-active="files"] .tab-glider { transform: translateX(200%); }

.tabs [role="tab"] {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 12px;
  font-weight: 600;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: 9px;
  transition: color .2s;
}
.tabs [role="tab"]:hover { color: var(--text); }
.tabs [role="tab"][aria-selected="true"] { color: var(--text); }
.tabs [role="tab"] .icon { width: 18px; height: 18px; }

.count:empty { display: none; }
.count {
  min-width: 20px;
  padding: 0 6px;
  font-size: 12px;
  line-height: 20px;
  font-weight: 650;
  text-align: center;
  color: var(--muted);
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 999px;
}
.count.live { color: var(--accent-text); background: var(--accent); border-color: var(--accent); }

/* ===== Panels ===== */

.panel {
  padding: 22px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: fade .2s ease-out;
}
@keyframes fade { from { opacity: 0; transform: translateY(3px); } }

.panel-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 14px; }

/* ===== Drop zone ===== */

.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 36px 16px 30px;
  text-align: center;
  background: linear-gradient(180deg, var(--card-2), var(--card));
  border: 2px dashed var(--border-strong);
  border-radius: 14px;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .15s;
}
.drop-zone * { pointer-events: none; }
.drop-zone:hover { border-color: var(--accent); }
.drop-zone.over { background: var(--accent-soft); border-color: var(--accent); transform: scale(1.01); }
.drop-zone p { margin: 0; }

.drop-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  margin-bottom: 12px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 50%;
  transition: transform .2s;
}
.drop-icon .icon { width: 28px; height: 28px; }
.drop-zone:hover .drop-icon, .drop-zone.over .drop-icon { transform: translateY(-3px); }

.drop-title { font-size: 16px; font-weight: 600; margin-bottom: 4px !important; }
.linkish { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

/* Whole-window drop target */
.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .15s, visibility .15s;
}
body.dragging .drop-overlay { opacity: 1; visibility: visible; }
.drop-overlay-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 40px 56px;
  font-size: 18px;
  font-weight: 650;
  color: var(--accent);
  background: var(--card);
  border: 2px dashed var(--accent);
  border-radius: 20px;
  box-shadow: var(--shadow);
}
.drop-overlay-inner p { margin: 0; }
.drop-overlay-inner .icon { width: 44px; height: 44px; }

/* ===== File-type tiles ===== */

.ftype {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  background: var(--t-other-bg);
  color: var(--t-other-fg);
  border-radius: 11px;
}
.fext { font-size: 11px; font-weight: 750; letter-spacing: .03em; }

.t-archive { background: var(--t-archive-bg); color: var(--t-archive-fg); }
.t-database { background: var(--t-database-bg); color: var(--t-database-fg); }
.t-pdf { background: var(--t-pdf-bg); color: var(--t-pdf-fg); }
.t-video { background: var(--t-video-bg); color: var(--t-video-fg); }
.t-audio { background: var(--t-audio-bg); color: var(--t-audio-fg); }
.t-image { background: var(--t-image-bg); color: var(--t-image-fg); }
.t-doc { background: var(--t-doc-bg); color: var(--t-doc-fg); }
.t-sheet { background: var(--t-sheet-bg); color: var(--t-sheet-fg); }
.t-slide { background: var(--t-slide-bg); color: var(--t-slide-fg); }
.t-app { background: var(--t-app-bg); color: var(--t-app-fg); }
.t-code { background: var(--t-code-bg); color: var(--t-code-fg); }

/* ===== Upload list ===== */

.upload-list { list-style: none; margin: 18px 0 0; padding: 0; }
.upload-list:empty { display: none; }

.up-item {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 14px 0;
  border-top: 1px solid var(--border);
  animation: rise .25s ease-out;
}

.up-body { flex: 1; min-width: 0; }
.up-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.up-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.up-size { flex-shrink: 0; }
.up-status { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.up-actions { display: flex; gap: 14px; flex-shrink: 0; }

.bar { height: 6px; margin: 8px 0 6px; background: var(--track); border-radius: 999px; overflow: hidden; }
.bar-fill { position: relative; height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width .25s linear; overflow: hidden; }

/* moving sheen while bytes are flowing, so it's obvious the upload is running */
.up-item.uploading .bar-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .45), transparent);
  transform: translateX(-100%);
  animation: sheen 1.4s ease-in-out infinite;
}
@keyframes sheen { to { transform: translateX(100%); } }

.up-item.queued .bar-fill { background: var(--border-strong); }
.up-item.paused .bar-fill { background: var(--warn); }
.up-item.paused .up-status { color: var(--warn); }
.up-item.done .bar-fill { background: var(--ok); }
.up-item.done .up-status { color: var(--ok); font-weight: 550; }
.up-item.error .bar-fill { background: var(--error); width: 100% !important; opacity: .35; }
.up-item.error .up-status { color: var(--error); }

/* ===== Files toolbar ===== */

.toolbar { display: flex; gap: 10px; align-items: center; }

.search {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  min-width: 0;
}
.search > .icon { position: absolute; left: 12px; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.search input {
  width: 100%;
  height: 38px;
  padding: 0 36px 0 38px;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.search input:focus { outline: none; background: var(--card); border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.search input::-webkit-search-cancel-button { cursor: pointer; }
.search kbd {
  position: absolute;
  right: 10px;
  padding: 0 6px;
  font: 600 12px/18px ui-monospace, Consolas, monospace;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 5px;
  pointer-events: none;
}
.search input:focus ~ kbd, .search input:not(:placeholder-shown) ~ kbd { display: none; }

#file-sort {
  height: 38px;
  padding: 0 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
}

.summary { margin: 14px 2px 4px; min-height: 1.5em; }

/* ===== File list ===== */

.file-list { list-style: none; margin: 0; padding: 0; }

.frow {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 10px;
  margin: 0 -10px;
  border-radius: 12px;
  transition: background .15s;
}
.frow + .frow { border-top: 1px solid var(--border); }
.frow:hover, .frow:focus-within { background: var(--card-2); }
.frow:hover + .frow, .frow:focus-within + .frow { border-top-color: transparent; }

.finfo { flex: 1; min-width: 0; }
.fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.fname mark { color: inherit; background: var(--mark); border-radius: 3px; padding: 0 1px; }
.fmeta { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.badge-new {
  margin-left: 4px;
  padding: 0 7px;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  color: var(--ok);
  background: var(--ok-soft);
  border-radius: 999px;
}

.dl-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
  padding: 8px 14px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid transparent;
  border-radius: 10px;
  transition: background .15s, color .15s, border-color .15s, transform .1s;
}
.dl-btn .icon { width: 18px; height: 18px; }
.dl-btn:hover:not(:disabled) { color: var(--accent-text); background: var(--accent); }
.dl-btn:active:not(:disabled) { transform: translateY(1px); }
.dl-btn[data-state="busy"] { opacity: .85; }
.dl-btn[data-state="busy"] .icon { animation: spin .8s linear infinite; }
.dl-btn[data-state="done"], .dl-btn[data-state="done"]:hover { color: var(--ok); background: var(--ok-soft); }

/* "Show in Files" highlight */
.frow.flash { animation: flash 2.2s ease-out; }
@keyframes flash {
  0%, 30% { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
  100% { background: transparent; box-shadow: inset 0 0 0 2px transparent; }
}

/* Loading placeholders */
.frow.skeleton .ftype, .sk-lines, .sk-btn {
  background: linear-gradient(90deg, var(--track) 0%, var(--card-2) 50%, var(--track) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}
.sk-lines { flex: 1; height: 30px; border-radius: 8px; max-width: 320px; }
.sk-btn { width: 112px; height: 36px; border-radius: 10px; margin-left: auto; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* Empty states */
.empty { padding: 40px 16px 28px; text-align: center; }
.empty p { margin: 0; }
.empty-art {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  margin: 0 auto 14px;
  color: var(--muted);
  background: var(--card-2);
  border: 1px dashed var(--border-strong);
  border-radius: 22px;
}
.empty-art .icon { width: 32px; height: 32px; }
.empty-title { font-size: 16px; font-weight: 650; margin-bottom: 4px !important; }
.empty .primary { margin-top: 18px; }

/* ===== Download password dialog ===== */

.pwd-dialog {
  width: min(420px, calc(100% - 32px));
  max-width: none;
  padding: 0;
  color: var(--text);
  background: transparent;
  border: 0;
  overflow: visible;
}
.pwd-dialog::backdrop {
  background: rgba(8, 12, 20, .45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.pwd-dialog[open] .pwd-card { animation: pop .2s cubic-bezier(.2, .8, .3, 1.1); }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.97); } }

.pwd-card {
  padding: 22px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 24px 64px -16px rgba(0, 0, 0, .45);
}

.pwd-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.pwd-head h2 { margin: 0; font-size: 17px; font-weight: 650; }
.pwd-head p { margin: 2px 0 0; }
.lock-badge.small-badge { width: 44px; height: 44px; margin: 0; border-radius: 13px; flex-shrink: 0; }
.lock-badge.small-badge .icon { width: 22px; height: 22px; }

.pwd-file {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  margin-bottom: 14px;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.pwd-file .ftype { width: 38px; height: 38px; border-radius: 10px; }

.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.dialog-actions .ghost { padding: 9px 16px; }
#pwd-ok .icon { width: 18px; height: 18px; }
#pwd-ok.loading .btn-spinner { display: block; }
#pwd-ok.loading .btn-icon { display: none; }
#pwd-msg { min-height: 1.4em; margin: 8px 2px 4px; text-align: left; font-size: 13px; }

/* ===== Toasts ===== */

.toasts {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(520px, calc(100% - 32px));
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 8px 10px 14px;
  font-size: 14px;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px) scale(.98);
  transition: opacity .2s, transform .2s;
  pointer-events: auto;
}
.toast.show { opacity: 1; transform: none; }
.toast-icon { width: 20px; height: 20px; }
.toast.ok .toast-icon { color: var(--ok); }
.toast.warn .toast-icon { color: var(--warn); }
.toast.error .toast-icon { color: var(--error); }
.toast.info .toast-icon { color: var(--accent); }
.toast-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast-action {
  flex-shrink: 0;
  padding: 5px 10px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: 0;
  border-radius: 8px;
}
.toast-close {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  padding: 0;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: 8px;
}
.toast-close:hover { color: var(--text); background: var(--card-2); }
.toast-close .icon { width: 16px; height: 16px; }

/* ===== Clipboard ===== */

kbd {
  display: inline-block;
  padding: 0 6px;
  font: 600 12px/19px ui-monospace, Consolas, monospace;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 6px;
}

.clip-paste {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: linear-gradient(180deg, var(--card-2), var(--card));
  border: 2px dashed var(--border-strong);
  border-radius: 14px;
  transition: background .15s, border-color .15s;
}
.clip-paste:hover, .clip-paste:focus-visible { border-color: var(--accent); outline: none; }
.clip-paste.busy { background: var(--accent-soft); border-color: var(--accent); }
.clip-paste.busy .drop-icon { animation: bob .9s ease-in-out infinite alternate; }
@keyframes bob { to { transform: translateY(-3px); } }
.clip-paste p { margin: 0; }
.clip-paste .drop-icon { width: 52px; height: 52px; margin: 0; flex-shrink: 0; }
.clip-paste .drop-icon .icon { width: 26px; height: 26px; }

.clip-compose { margin-top: 12px; }
#clip-text {
  display: block;
  width: 100%;
  min-height: 60px;
  max-height: 40vh;
  padding: 10px 12px;
  font: 13px/1.5 ui-monospace, Consolas, monospace;
  color: var(--text);
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  resize: vertical;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
#clip-text:focus { outline: none; background: var(--card); border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.clip-compose-actions { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.clip-compose-actions .grow { flex: 1; }
#clip-send { padding: 8px 16px; }
#clip-send .icon { width: 17px; height: 17px; }

.clip-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 1.5em; margin: 18px 2px 4px; }
.link.danger { color: var(--error); }

.clip-list { list-style: none; margin: 0; padding: 0; }
.clip { padding: 14px 0; border-top: 1px solid var(--border); animation: rise .25s ease-out; }
.clip:first-child { border-top: 0; }
.clip-top { display: flex; align-items: center; gap: 14px; }
.clip-kind .icon { width: 22px; height: 22px; }
.clip-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.clip-actions .icon-btn .icon { width: 18px; height: 18px; }
.clip-delete:hover { color: var(--error); }

.clip-body:empty { display: none; }
.clip-body { margin: 10px 0 0 58px; }
.clip-text {
  margin: 0;
  padding: 10px 12px;
  font: 13px/1.5 ui-monospace, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 60vh;
  overflow: auto;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.clip-text.clamped {
  max-height: calc(1.5em * 8 + 20px);
  overflow: hidden;
  -webkit-mask-image: linear-gradient(180deg, #000 65%, transparent);
  mask-image: linear-gradient(180deg, #000 65%, transparent);
}
.clip-more { margin-top: 6px; }

.clip-img {
  display: block;
  max-width: 100%;
  max-height: 320px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: repeating-conic-gradient(var(--card-2) 0 25%, var(--card) 0 50%) 0 0 / 16px 16px;
  cursor: zoom-in;
}
.clip-img:not([src]) { width: 220px; height: 120px; }
.clip-tip { margin: 6px 0 0; }

.offscreen { position: fixed; top: 0; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* ===== Small screens ===== */

@media (max-width: 600px) {
  .topbar { padding: 10px 16px; }
  .brand-name { display: none; }
  .tabs [role="tab"] { gap: 6px; padding: 9px 6px; }
  .clip-body { margin-left: 0; }
  .clip-from, .clip-from-dot, .kbd-hint { display: none; }
  .clip-paste { padding: 14px; }
  #change-pw-btn .btn-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .shell { padding-top: 16px; }
  .tabs { max-width: none; }
  .panel { padding: 16px; }
  .login-card { padding: 28px 20px 22px; }
  .toolbar { flex-wrap: wrap; }
  .search { flex-basis: 100%; }
  #file-sort { flex: 1; }
  .dl-btn { padding: 9px; }
  .dl-btn .dl-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .up-actions { gap: 10px; }
  .ftype { width: 40px; height: 40px; }
}

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