/* ---------- Shared ---------- */
body.cloud { min-height: 100svh; }
[hidden] { display: none !important; }

.cloud-loading { display: grid; place-items: center; min-height: 100svh; }
.spinner {
  display: block;
  width: 2rem;
  height: 2rem;
  border: 3px solid var(--line);
  border-block-start-color: var(--brand);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.field { display: grid; gap: .35rem; font-size: .88rem; }
.field > span { color: var(--muted); }
.field input, .field select {
  width: 100%;
  padding: .65rem .85rem;
  border: 1px solid var(--line);
  border-radius: .75rem;
  background: var(--ink);
  color: var(--fg);
  font: inherit;
  transition: border-color .2s;
}
.field input:focus, .field select:focus { border-color: var(--brand); outline: none; }
.check { display: flex; align-items: center; gap: .55rem; font-size: .92rem; }
.check input { width: 1.05rem; height: 1.05rem; accent-color: var(--brand-2); }

.form-error {
  padding: .55rem .8rem;
  border: 1px solid color-mix(in oklab, #f87171 40%, transparent);
  border-radius: .7rem;
  background: color-mix(in oklab, #f87171 10%, transparent);
  color: #fca5a5;
  font-size: .86rem;
  line-height: 1.7;
}

.link-button { color: var(--muted); font-size: .86rem; transition: color .2s; }
.link-button:hover { color: var(--fg); }

.btn-quiet {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--fg);
}
.btn-quiet:hover { background: var(--ink-2); }
.btn-danger { border: 1px solid color-mix(in oklab, #f87171 45%, transparent); color: #fca5a5; }
.btn-compact { padding: .5rem 1rem; border-radius: .75rem; font-size: .88rem; }

.footer-version { color: var(--muted); font-size: .76rem; }

/* ---------- Login ---------- */
.login-page {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 100svh;
  padding: 1.5rem var(--gutter);
  overflow: hidden;
  background: radial-gradient(50% 45% at 50% 25%, color-mix(in oklab, var(--brand-2) 22%, transparent), transparent 75%);
}
.login-bg { position: absolute; inset: 0; pointer-events: none; }
.login-card {
  display: grid;
  gap: 1.1rem;
  width: min(100%, 24rem);
  padding: 2rem;
}
.login-card > * { position: relative; }
.login-card h1 { font-size: 1.35rem; font-weight: 800; line-height: 1.5; }
.login-note { color: var(--muted); font-size: .82rem; text-align: center; }
.login-card .footer-version { text-align: center; }
#unavailable .login-note { text-align: start; line-height: 1.8; }
.login-card .spinner { justify-self: center; }
.share-file { display: grid; gap: .8rem; }
.share-file h1 { font-size: 1.35rem; font-weight: 800; line-height: 1.5; }
.share-name { overflow-wrap: anywhere; font-weight: 600; line-height: 1.7; }
.share-file .login-note { text-align: start; line-height: 1.8; }

/* ---------- App frame ---------- */
.cloud-app { display: flex; flex-direction: column; min-height: 100svh; }
.cloud-header {
  position: sticky;
  inset-block-start: 0;
  z-index: 30;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .6rem 1.5rem;
  padding: .7rem var(--gutter);
  border-block-end: 1px solid var(--line);
  background: rgb(10 12 28 / .88);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}
.cloud-nav { display: flex; gap: .25rem; }
.cloud-nav svg { display: none; }
.cloud-nav button {
  padding: .4rem .9rem;
  border-radius: .65rem;
  color: var(--muted);
  font-size: .9rem;
  transition: color .2s, background-color .2s;
}
.cloud-nav button:hover { color: var(--fg); }
.cloud-nav button[aria-current="page"] { background: var(--surface); color: var(--fg); }
.cloud-user { display: flex; align-items: center; gap: .9rem; font-size: .88rem; }
.user-picture { flex-shrink: 0; width: 1.9rem; height: 1.9rem; margin-inline-end: -.45rem; border-radius: 50%; object-fit: cover; background: var(--ink-2); }
.connection-note {
  padding: .45rem var(--gutter);
  background: color-mix(in oklab, #f59e0b 16%, var(--ink-2));
  color: #fcd34d;
  font-size: .82rem;
  line-height: 1.7;
  text-align: center;
}
.cloud-main { flex: 1; padding-block: 2rem 3rem; }
.cloud-footer { padding: 1rem var(--gutter); border-block-start: 1px solid var(--line); text-align: center; }

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-block-end: 1.5rem;
}
.page-head h1 { font-size: clamp(1.4rem, 1.2rem + .9vw, 1.9rem); font-weight: 800; line-height: 1.4; }
.page-head p { color: var(--muted); font-size: .92rem; }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; }

.segmented {
  display: flex;
  padding: .2rem;
  border: 1px solid var(--line);
  border-radius: .8rem;
  background: var(--ink-2);
}
.segmented button { padding: .35rem .85rem; border-radius: .6rem; color: var(--muted); font-size: .86rem; }
.segmented button[aria-pressed="true"] { background: var(--fg); color: var(--ink); font-weight: 600; }

/* ---------- Files ---------- */
.files-page { position: relative; border-radius: var(--radius-lg); }
.files-page.is-dragging { outline: 2px dashed var(--brand); outline-offset: .75rem; }

.file-list { display: grid; gap: .6rem; }
.file-list + .file-list { margin-block-start: 1.25rem; }
.file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .9rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--ink-2);
}
.file-main { flex: 1; min-width: 0; }
.file-main strong { display: block; overflow-wrap: anywhere; font-weight: 600; line-height: 1.6; }
.file-main small { display: block; color: var(--muted); font-size: .8rem; line-height: 1.7; }
.file-main progress {
  display: block;
  width: 100%;
  height: .4rem;
  margin-block-start: .5rem;
  overflow: hidden;
  border: 0;
  border-radius: 1rem;
  background: var(--line);
  accent-color: var(--brand);
  appearance: none;
}
.file-main progress::-webkit-progress-bar { background: var(--line); }
.file-main progress::-webkit-progress-value { background: linear-gradient(90deg, var(--brand), var(--brand-2)); }
.file-main progress::-moz-progress-bar { background: linear-gradient(90deg, var(--brand), var(--brand-2)); }

.row-actions { display: flex; flex-shrink: 0; gap: .35rem; }
.icon-button {
  display: grid;
  place-items: center;
  width: 2.35rem;
  height: 2.35rem;
  border: 1px solid var(--line);
  border-radius: .7rem;
  background: var(--surface);
  color: var(--fg);
  transition: border-color .2s, color .2s;
}
.icon-button:hover { border-color: var(--brand); color: var(--brand); }
.icon-button.danger:hover { border-color: #f87171; color: #fca5a5; }
.icon-button svg { width: 1.1rem; height: 1.1rem; }

.tool-row { transition: border-color .2s; }
.tool-row:hover { border-color: var(--brand); }

.empty-state {
  padding: 3rem 1.5rem;
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
  color: var(--muted);
  font-size: .94rem;
  text-align: center;
}

/* ---------- Users ---------- */
.user-row .pill { display: inline-block; margin-inline-start: .35rem; padding: 0 .55rem; border-radius: 1rem; font-size: .72rem; line-height: 1.7; vertical-align: middle; }
.pill-admin { background: color-mix(in oklab, var(--brand-2) 28%, transparent); color: #c4b5fd; }
.pill-off { background: color-mix(in oklab, #f87171 16%, transparent); color: #fca5a5; }
.pill-git { background: color-mix(in oklab, #fb923c 18%, transparent); color: #fdba74; }

/* ---------- Password ---------- */
.narrow-form {
  display: grid;
  gap: 1rem;
  width: min(100%, 26rem);
  padding: 1.5rem;
}
.narrow-form > * { position: relative; }

/* ---------- Modal ---------- */
.modal {
  width: min(calc(100% - 2rem), 30rem);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--ink-2);
  color: var(--fg);
}
.modal::backdrop { background: rgb(5 6 15 / .75); }
.modal-card { display: grid; gap: 1rem; padding: 1.5rem; }
.modal-card h2 { font-size: 1.15rem; font-weight: 700; line-height: 1.6; }
.modal-card > p { color: var(--muted); font-size: .88rem; overflow-wrap: anywhere; }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .5rem; }
.share-list { display: grid; gap: .5rem; max-height: 16rem; margin: 0; padding: .9rem; overflow-y: auto; border: 1px solid var(--line); border-radius: .85rem; }
.share-list legend { padding-inline: .4rem; color: var(--muted); font-size: .84rem; }
.share-all { padding-block-end: .5rem; border-block-end: 1px solid var(--line); }
.link-list { display: grid; gap: .5rem; font-size: .84rem; }
.link-list > span { color: var(--muted); }
.link-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .45rem .75rem;
  border: 1px solid var(--line);
  border-radius: .75rem;
  line-height: 1.7;
}

/* ---------- Toasts ---------- */
.toasts {
  position: fixed;
  z-index: 60;
  inset-block-end: 1.25rem;
  inset-inline: 1rem;
  display: grid;
  justify-items: center;
  gap: .5rem;
  pointer-events: none;
}
.toast {
  max-width: 34rem;
  padding: .6rem 1rem;
  border: 1px solid color-mix(in oklab, var(--accent) 35%, var(--line));
  border-radius: .85rem;
  background: var(--surface);
  font-size: .88rem;
  line-height: 1.7;
}
.toast.is-error { border-color: color-mix(in oklab, #f87171 50%, var(--line)); color: #fca5a5; }

/* ---------- Phones: tab bar at the bottom, dialogs as bottom sheets ---------- */
@media (max-width: 40rem) {
  .file-row { align-items: stretch; flex-direction: column; gap: .65rem; }
  .tool-row { align-items: center; flex-direction: row; }
  .row-actions { justify-content: flex-end; }

  /* A backdrop filter would make the header the containing block of the fixed tab bar inside it. */
  .cloud-header {
    flex-wrap: nowrap;
    background: var(--ink-2);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .cloud-user { min-width: 0; }
  #user-name { min-width: 0; max-width: 7rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .cloud-nav {
    position: fixed;
    inset-block-end: 0;
    inset-inline: 0;
    z-index: 40;
    gap: 0;
    padding: .25rem .5rem;
    border-block-start: 1px solid var(--line);
    background: var(--ink-2);
  }
  .cloud-nav button {
    display: grid;
    flex: 1;
    justify-items: center;
    gap: .1rem;
    min-width: 0;
    padding: .35rem .15rem;
    font-size: .72rem;
    line-height: 1.5;
  }
  .cloud-nav svg { display: block; width: 1.35rem; height: 1.35rem; }
  .cloud-nav button[aria-current="page"] { background: none; color: var(--brand); }

  .cloud-main { padding-block-start: 1.25rem; }
  .cloud-footer { padding-block-end: 5rem; }
  .page-actions, .page-actions .segmented { width: 100%; }
  .page-actions .segmented button { flex: 1; }
  .page-actions .btn { width: 100%; }
  .toasts { inset-block-end: 4.75rem; }

  .modal {
    width: 100%;
    max-width: 100%;
    max-height: 90dvh;
    margin: auto 0 0;
    border-block-end: 0;
    border-end-start-radius: 0;
    border-end-end-radius: 0;
  }
  .modal-actions .btn { flex: 1; }
}

@media (max-width: 24rem) {
  .cloud-header .logo-text { display: none; }
}

/* ---------- Touch screens ---------- */
body.cloud { -webkit-tap-highlight-color: transparent; }

@media (pointer: coarse) {
  body.cloud { overscroll-behavior-y: none; }
  .icon-button { width: 2.75rem; height: 2.75rem; }
  .btn-compact { min-height: 2.75rem; }
  .link-button { min-height: 2.75rem; padding-inline: .5rem; }
  .segmented button { min-height: 2.5rem; }
  .check { min-height: 2.75rem; }
  .check input { width: 1.35rem; height: 1.35rem; }
  /* Below 16px, iPhones zoom the whole page when a field gets focus. */
  .field input, .field select { font-size: 1rem; }
}
