/* ============================================================================
 * Sky — the WeDoFiles house style, layered onto Bulma.
 *
 * Direction 3a from the design docs: deep navy that stays out of the way, one
 * bright cyan that only ever means "this is yours to act on", generous
 * rounding. Figtree carries the language, Chivo Mono carries every number.
 *
 * Bulma 1.x is themed entirely through CSS custom properties, so this file sets
 * variables rather than overriding rules. That matters for upgrades: a Bulma
 * point release can change a selector, but --bulma-primary-h is a contract.
 *
 * Light mode follows the 16a mapping. Hues stay put and only lightness moves,
 * with one exception spelled out there: #35D0EE is 1.8:1 on white and unusable
 * for text, so light mode reads cyan at #0C7C96 and keeps the bright value only
 * for meter fills, where it is a shape rather than a word.
 * ========================================================================== */

:root {
  /* --- Sky palette, dark (the default) --- */
  --sky-deep:    #0A1017;  /* page */
  --sky-panel:   #121A24;  /* cards, panels */
  --sky-panel-2: #16202B;  /* nested surfaces, table headers */
  --sky-edge:    #1F2C3A;  /* the 1px rim that stands in for elevation */
  --sky-bright:  #E8F0F7;  /* body text */
  --sky-muted:   #8FA3B5;  /* secondary text */

  --sky-cyan:      #35D0EE; /* action, and only action */
  --sky-cyan-text: #35D0EE; /* readable cyan — diverges from the fill in light */
  --sky-cyan-fill: #35D0EE; /* meter fills */
  --sky-action-ink: #0A1017;
  --sky-action-hover: #68DDF2;
  --sky-go:        #3EDC9B;
  --sky-warn:      #F5B944;
  --sky-stop:      #FF6A6A;
  --sky-acted:     #7E8CFF; /* "we acted on this" — distinct from stop */

  /* Space: 4 · 8 · 12 · 20 · 32 · 52 */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px;
  --sp-4: 20px; --sp-5: 32px; --sp-6: 52px;

  /* Radius: 9px on controls and rows, 16px on panels, pill on primary buttons */
  --r-control: 9px;
  --r-panel:   16px;
  --r-pill:    999px;

  --font-ui:   "Figtree", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "Chivo Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Elevation is a 1px lighter rim, never a drop shadow. The upload target is
   * the single exception the design allows, and it uses --shadow-lift below. */
  --shadow-lift: 0 8px 32px rgba(0, 0, 0, 0.45);

  color-scheme: dark;
}

:root[data-theme="light"] {
  --sky-deep:    #F4F7FA;
  --sky-panel:   #FFFFFF;
  --sky-panel-2: #F4F7FA;
  --sky-edge:    #DCE4EC;
  --sky-bright:  #0E1720;
  --sky-muted:   #5A6B7D;

  --sky-cyan:       #0C7C96;
  --sky-cyan-text:  #0C7C96;
  --sky-cyan-fill:  #12A5C4;
  --sky-action-ink: #FFFFFF;
  --sky-action-hover: #09677C;
  --sky-go:         #0F7A57;
  --sky-warn:       #9A6B08;
  --sky-stop:       #B32D2D;
  --sky-acted:      #4A50B8;

  --shadow-lift: 0 8px 24px rgba(14, 23, 32, 0.12);
  color-scheme: light;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --sky-deep:    #F4F7FA;
    --sky-panel:   #FFFFFF;
    --sky-panel-2: #F4F7FA;
    --sky-edge:    #DCE4EC;
    --sky-bright:  #0E1720;
    --sky-muted:   #5A6B7D;

    --sky-cyan:       #0C7C96;
    --sky-cyan-text:  #0C7C96;
    --sky-cyan-fill:  #12A5C4;
    --sky-action-ink: #FFFFFF;
    --sky-action-hover: #09677C;
    --sky-go:         #0F7A57;
    --sky-warn:       #9A6B08;
    --sky-stop:       #B32D2D;
    --sky-acted:      #4A50B8;

    --shadow-lift: 0 8px 24px rgba(14, 23, 32, 0.12);
    color-scheme: light;
  }
}

/* ---------------------------------------------------------------------------
 * Bulma variable remapping.
 * Bulma derives most of its palette from h/s/l triples, so setting those gives
 * consistent hover, active, and inverted variants for free.
 * ------------------------------------------------------------------------ */
:root {
  --bulma-family-primary: var(--font-ui);
  --bulma-family-code: var(--font-mono);
  --bulma-family-monospace: var(--font-mono);

  --bulma-scheme-h: 210;
  --bulma-scheme-s: 40%;
  --bulma-light-l: 92%;
  --bulma-dark-l: 8%;

  --bulma-primary-h: 190;
  --bulma-primary-s: 84%;
  --bulma-primary-l: 57%;

  --bulma-link-h: 190;
  --bulma-link-s: 84%;
  --bulma-link-l: 57%;

  --bulma-success-h: 158;
  --bulma-success-s: 70%;
  --bulma-success-l: 55%;

  --bulma-warning-h: 40;
  --bulma-warning-s: 90%;
  --bulma-warning-l: 62%;

  --bulma-danger-h: 0;
  --bulma-danger-s: 100%;
  --bulma-danger-l: 71%;

  --bulma-body-background-color: var(--sky-deep);
  --bulma-body-color: var(--sky-bright);
  --bulma-text: var(--sky-bright);
  --bulma-text-strong: var(--sky-bright);
  --bulma-text-weak: var(--sky-muted);
  --bulma-border: var(--sky-edge);
  --bulma-border-weak: var(--sky-edge);

  --bulma-radius-small: 6px;
  --bulma-radius: var(--r-control);
  --bulma-radius-large: var(--r-panel);
  --bulma-radius-rounded: var(--r-pill);

  --bulma-link-text: var(--sky-cyan-text);
  --bulma-link-text-hover: var(--sky-cyan-text);
}

/* ---------------------------------------------------------------------------
 * Type scale: 46/1.02 · 32/1.1 · 22/1.25 · 16/1.6 · 14.5/1.65 · 13/1.5 ·
 * 10/1 caps .16em
 * ------------------------------------------------------------------------ */
html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--sky-deep);
  color: var(--sky-bright);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.6;
  font-weight: 400;
}

[hidden] { display: none !important; }

.t-display { font: 700 46px/1.02 var(--font-ui); letter-spacing: -0.02em; }
.t-h1      { font: 700 32px/1.1  var(--font-ui); letter-spacing: -0.015em; }
.t-h2      { font: 600 22px/1.25 var(--font-ui); letter-spacing: -0.01em; }
.t-body    { font: 400 16px/1.6  var(--font-ui); }
.t-ui      { font: 600 14.5px/1.65 var(--font-ui); }
.t-small   { font: 400 13px/1.5  var(--font-ui); }
.t-label {
  font: 500 10px/1 var(--font-mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--sky-muted);
}

/* Every size, ID, price, date and percentage is mono. Fixed width means a
 * number the page re-polls every 3 seconds never nudges the layout — which is
 * why the upload and scan screens do not jitter while they update. */
.num, .mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

@media (max-width: 768px) {
  .t-display { font-size: 34px; }
  .t-h1      { font-size: 26px; }
}

/* ---------------------------------------------------------------------------
 * Surfaces
 * ------------------------------------------------------------------------ */
.panel-sky {
  background: var(--sky-panel);
  border: 1px solid var(--sky-edge);
  border-radius: var(--r-panel);
}

.panel-sky__head {
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--sky-edge);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
}
.panel-sky__body { padding: var(--sp-4) var(--sp-5); }

.rule { height: 1px; background: var(--sky-edge); border: 0; margin: var(--sp-4) 0; }

/* ---------------------------------------------------------------------------
 * The signature element: a pill meter with a ghost.
 *
 * The second, translucent fill shows what a pending action *would* add, so the
 * consequence is visible before the server does anything. It is used on the
 * dashboard, in the upload queue, on plan comparison, and on the add-on stepper
 * — one component, four places, which is what makes it a signature rather than
 * a decoration.
 * ------------------------------------------------------------------------ */
.meter {
  --meter-fill: var(--sky-cyan-fill);
  display: block;
}

.meter__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-2);
}

.meter__value { font: 600 22px/1.25 var(--font-mono); color: var(--sky-bright); }
.meter__of    { font: 400 13px/1.5 var(--font-ui); color: var(--sky-muted); }

/* The ghost's own number, e.g. "7.4 + 5.1 / 250 GB" */
.meter__ghost-value { color: var(--meter-fill); }

.meter__track {
  position: relative;
  height: 10px;
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--sky-edge) 70%, transparent);
  overflow: hidden;
}

.meter__fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: var(--r-pill);
  background: var(--meter-fill);
  /* A small non-zero minimum so 3% of 250 GB is still a visible shape rather
   * than a hairline the eye reads as empty (design note in 8b). */
  min-width: 6px;
  transition: width 240ms ease;
}

.meter__ghost {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--meter-fill) 34%, transparent);
  transition: width 240ms ease, left 240ms ease;
}

.meter__foot {
  margin-top: var(--sp-2);
  font: 400 13px/1.5 var(--font-ui);
  color: var(--sky-muted);
}

.meter--warn { --meter-fill: var(--sky-warn); }
.meter--over { --meter-fill: var(--sky-stop); }
.meter--go   { --meter-fill: var(--sky-go); }

/* ---------------------------------------------------------------------------
 * State pills.
 *
 * Quarantined is solid and red-rimmed — a sealed thing we stopped from reaching
 * you. Disabled is dashed, unfilled and paired with a struck-through name — a
 * thing withdrawn, with an appeal. Different colour AND different shape, so the
 * distinction survives greyscale and colour-blindness both.
 * ------------------------------------------------------------------------ */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  border: 1px solid transparent;
  font: 500 12px/1.4 var(--font-mono);
  white-space: nowrap;
}

.pill--available   { color: var(--sky-go);    border-color: color-mix(in srgb, var(--sky-go) 40%, transparent);
                     background: color-mix(in srgb, var(--sky-go) 12%, transparent); }
.pill--uploading,
.pill--scanning    { color: var(--sky-cyan-text); border-color: color-mix(in srgb, var(--sky-cyan) 40%, transparent);
                     background: color-mix(in srgb, var(--sky-cyan) 12%, transparent); }
.pill--quarantined { color: var(--sky-deep);  border-color: var(--sky-stop);
                     background: var(--sky-stop); font-weight: 700; }
.pill--disabled    { color: var(--sky-acted); border-color: var(--sky-acted);
                     border-style: dashed; background: transparent; }
.pill--error       { color: var(--sky-warn);  border-color: color-mix(in srgb, var(--sky-warn) 45%, transparent);
                     background: color-mix(in srgb, var(--sky-warn) 12%, transparent); }
.pill--private     { color: var(--sky-muted); border-color: var(--sky-edge); }
.pill--public      { color: var(--sky-cyan-text); border-color: color-mix(in srgb, var(--sky-cyan) 40%, transparent); }

/* Paired with .pill--disabled: the name is struck because the thing itself was
 * withdrawn, not merely flagged. */
.name--withdrawn { text-decoration: line-through; text-decoration-thickness: 1px; color: var(--sky-muted); }

/* ---------------------------------------------------------------------------
 * Controls
 * ------------------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 10px 18px;
  border-radius: var(--r-pill);
  border: 1px solid var(--sky-edge);
  background: transparent;
  color: var(--sky-bright);
  font: 600 14.5px/1 var(--font-ui);
  cursor: pointer;
  text-decoration: none;
  transition: background 140ms ease, border-color 140ms ease, opacity 140ms ease;
}
.btn:hover  { border-color: color-mix(in srgb, var(--sky-cyan) 50%, var(--sky-edge)); color: var(--sky-bright); }
.btn:focus-visible { outline: 2px solid var(--sky-cyan); outline-offset: 2px; }

.btn--primary {
  background: var(--sky-cyan);
  border-color: var(--sky-cyan);
  color: var(--sky-action-ink);
}
.btn--primary:hover { 
  background: var(--sky-action-hover);
  border-color: var(--sky-action-hover);
  color: color-mix(
    in srgb,
    var(--sky-action-ink) 85%,
    light-dark(#0A1017, #FFFFFF)
  );
}

.btn--danger { border-color: var(--sky-stop); color: var(--sky-stop); }
.btn--danger:hover { background: color-mix(in srgb, var(--sky-stop) 12%, transparent); }

.btn--quiet { border-color: transparent; color: var(--sky-muted); padding-inline: 10px; }
.btn--quiet:hover { color: var(--sky-bright); border-color: var(--sky-edge); }

.btn--small { padding: 6px 12px; font-size: 13px; }

.btn:disabled,
.btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

/* Pending state. The design is explicit that nothing is optimistic: the same
 * verb goes to present tense and the control stops accepting input until the
 * server answers. */
.btn[aria-busy="true"] { opacity: 0.6; pointer-events: none; }

/* Fields ------------------------------------------------------------------ */
.field-sky { margin-bottom: var(--sp-4); }
.field-sky__label {
  display: block;
  margin-bottom: var(--sp-2);
  font: 600 14.5px/1.4 var(--font-ui);
  color: var(--sky-bright);
}
.field-sky__hint { margin-top: 6px; font: 400 13px/1.5 var(--font-ui); color: var(--sky-muted); }
.field-sky__error {
  margin-top: 6px;
  font: 400 13px/1.5 var(--font-ui);
  color: var(--sky-stop);
}

.input-sky {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--r-control);
  border: 1px solid var(--sky-edge);
  background: var(--sky-deep);
  color: var(--sky-bright);
  font: 400 16px/1.4 var(--font-ui); /* 16px so iOS Safari does not zoom on focus */
}
.input-sky:focus {
  outline: none;
  border-color: var(--sky-cyan);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--sky-cyan) 22%, transparent);
}
.input-sky[aria-invalid="true"] { border-color: var(--sky-stop); }
.input-sky::placeholder { color: color-mix(in srgb, var(--sky-muted) 70%, transparent); }
.input-sky:disabled, .input-sky[readonly] { opacity: 0.6; }

/* An ID or a URL next to a copy button. */
.copyfield {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 8px 8px 8px 14px;
  border: 1px solid var(--sky-edge);
  border-radius: var(--r-control);
  background: var(--sky-deep);
}
.copyfield__value {
  flex: 1;
  min-width: 0;
  font: 400 13px/1.4 var(--font-mono);
  color: var(--sky-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------------------------------------------------------------------------
 * Notices — the banner language the design uses for payment failure, capacity,
 * and moderation. Each carries its own accent; none of them use cyan, which is
 * reserved for things the reader can act on.
 * ------------------------------------------------------------------------ */
.notice {
  --notice-accent: var(--sky-muted);
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid color-mix(in srgb, var(--notice-accent) 40%, transparent);
  border-left: 3px solid var(--notice-accent);
  border-radius: var(--r-control);
  background: color-mix(in srgb, var(--notice-accent) 9%, transparent);
  font: 400 14.5px/1.6 var(--font-ui);
}
.notice--warn  { --notice-accent: var(--sky-warn); }
.notice--stop  { --notice-accent: var(--sky-stop); }
.notice--acted { --notice-accent: var(--sky-acted); }
.notice--go    { --notice-accent: var(--sky-go); }
.notice--info  { --notice-accent: var(--sky-cyan); }
.notice__title { font-weight: 700; display: block; }

/* ---------------------------------------------------------------------------
 * File rows.
 *
 * Each row is its own HTMX fragment, so a rename or a status change swaps one
 * row and nothing else moves. While a swap is in flight the row keeps its exact
 * height and dims: the list must never reflow under the reader's cursor.
 * ------------------------------------------------------------------------ */
.filerow {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-control);
  border: 1px solid transparent;
  transition: background 120ms ease, opacity 120ms ease;
}
.filerow:hover { background: var(--sky-panel-2); }
.filerow + .filerow { border-top: 1px solid var(--sky-edge); border-radius: 0; }

.filerow__name {
  min-width: 0;
  font: 600 14.5px/1.4 var(--font-ui);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.filerow__meta { font: 400 13px/1.5 var(--font-ui); color: var(--sky-muted); }
.filerow__size, .filerow__date { font-family: var(--font-mono); font-size: 13px; color: var(--sky-muted); }

.filerow--quarantined { border-color: color-mix(in srgb, var(--sky-stop) 45%, transparent); }
.filerow--disabled    { border-color: color-mix(in srgb, var(--sky-acted) 45%, transparent); border-style: dashed; }

/* htmx-request is added by HTMX for the duration of an in-flight swap. */
.filerow.htmx-request { opacity: 0.5; pointer-events: none; }

/* Inline progress inside a row, for an upload in flight. */
.filerow__progress {
  grid-column: 1 / -1;
  height: 4px;
  border-radius: var(--r-pill);
  background: var(--sky-edge);
  overflow: hidden;
}
.filerow__progress > i {
  display: block;
  height: 100%;
  background: var(--sky-cyan-fill);
  border-radius: var(--r-pill);
}

@media (max-width: 768px) {
  .filerow { grid-template-columns: 1fr auto; }
  .filerow__date { display: none; }
}

/* ---------------------------------------------------------------------------
 * App shell
 * ------------------------------------------------------------------------ */
.shell { display: grid; grid-template-columns: 264px 1fr; min-height: 100vh; }

.shell__side {
  border-right: 1px solid var(--sky-edge);
  padding: var(--sp-5) var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
  background: var(--sky-panel);
}
.shell__main { padding: var(--sp-5); max-width: 1180px; width: 100%; }
.shell__mobile-tools { display: none; }

.navlink {
  display: block;
  padding: 8px 12px;
  border-radius: var(--r-control);
  color: var(--sky-muted);
  font: 600 14.5px/1.4 var(--font-ui);
  text-decoration: none;
}
.navlink:hover { background: var(--sky-panel-2); color: var(--sky-bright); }
.navlink[aria-current="page"] { background: var(--sky-panel-2); color: var(--sky-bright); }

.brand { display: inline-flex; align-items: center; gap: var(--sp-2); text-decoration: none; }
.brand__dot {
  width: 10px; height: 10px; border-radius: 3px;
  background: var(--sky-cyan);
  box-shadow: 0 0 14px color-mix(in srgb, var(--sky-cyan) 55%, transparent);
}
.brand__name {
  font: 500 11px/1 var(--font-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--sky-cyan-text);
}

.theme-toggle__icon {
  width: 1.2em;
  font-size: 16px;
  line-height: 1;
  text-align: center;
}

/* The mobile tab bar from screens 4c and 8d. Hidden on desktop, where the
 * sidebar does the same job. */
.tabbar { display: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .shell__side { display: none; }
  .shell__main { padding: var(--sp-4) var(--sp-3) 84px; }
  .shell__mobile-tools {
    display: flex;
    justify-content: flex-end;
    margin-bottom: var(--sp-3);
  }
  .tabbar {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    position: fixed;
    inset: auto 0 0 0;
    background: var(--sky-panel);
    border-top: 1px solid var(--sky-edge);
    padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
    z-index: 40;
  }
  .tabbar a,
  .tabbar button {
    text-align: center;
    min-height: 44px;
    padding: 6px 2px;
    font: 600 11px/1.4 var(--font-ui);
    color: var(--sky-muted);
    text-decoration: none;
  }
  .tabbar a[aria-current="page"] { color: var(--sky-cyan-text); }
  .tabbar button {
    align-self: center;
    margin-top: -18px;
    border: 1px solid var(--sky-cyan);
    border-radius: var(--r-pill);
    background: var(--sky-cyan);
    color: var(--sky-action-ink);
    cursor: pointer;
    box-shadow: var(--shadow-lift);
  }
}

/* Public pages (landing, pricing, share, auth) have no sidebar. */
.page { max-width: 1080px; margin: 0 auto; padding: var(--sp-5) var(--sp-4) var(--sp-6); }
.page--narrow { max-width: 460px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-4);
  border-bottom: 1px solid var(--sky-edge);
}
.topbar__links { display: flex; align-items: center; gap: var(--sp-4); }
/* :not(.btn) matters: without it this rule outranks .btn--primary on
 * specificity and paints the "Create an account" button's label muted cyan on
 * a cyan pill, which is invisible. Nav links are styled here; buttons keep
 * their own colours wherever they appear. */
.topbar__links a:not(.btn) { color: var(--sky-muted); text-decoration: none; font: 600 14.5px/1 var(--font-ui); }
.topbar__links a:not(.btn):hover { color: var(--sky-bright); }

.footer-sky {
  border-top: 1px solid var(--sky-edge);
  margin-top: var(--sp-6);
  padding: var(--sp-5) var(--sp-4);
  color: var(--sky-muted);
  font-size: 13px;
}
.footer-sky a { color: var(--sky-muted); text-decoration: none; }
.footer-sky a:hover { color: var(--sky-bright); }

/* ---------------------------------------------------------------------------
 * Layout helpers.
 *
 * Vertical rhythm is owned by the containing stack, never by its children:
 * 8px for tightly related controls, 20px for normal groups, and 32px between
 * page sections. This keeps grids, panels, and fragments on the same rhythm.
 * ------------------------------------------------------------------------ */
.stack-2 { display: flex; flex-direction: column; gap: var(--sp-2); }
.stack,
.stack-4 { display: flex; flex-direction: column; gap: var(--sp-4); }
.stack-5 { display: flex; flex-direction: column; gap: var(--sp-5); }
.row     { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.grid-2  { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-4); }
.grid-3  { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-4); }
.muted   { color: var(--sky-muted); }
.cyan    { color: var(--sky-cyan-text); }
.stop    { color: var(--sky-stop); }
.go      { color: var(--sky-go); }
.warn    { color: var(--sky-warn); }
.acted   { color: var(--sky-acted); }
.grow    { flex: 1; min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 900px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* Screen-reader-only text, for the labels a control needs and a sighted reader
 * gets from context. */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* Skip link — the first focusable thing on every page. */
.skip-link {
  position: absolute; left: -9999px;
  background: var(--sky-cyan); color: var(--sky-action-ink);
  padding: 10px 16px; border-radius: var(--r-control); z-index: 100;
}
.skip-link:focus { left: var(--sp-3); top: var(--sp-3); }

/* ---------------------------------------------------------------------------
 * HTMX
 * ------------------------------------------------------------------------ */
.htmx-indicator { opacity: 0; transition: opacity 160ms ease; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { opacity: 1; }

/* A swapping region keeps its height and dims rather than collapsing, so the
 * page below it does not jump while a fragment is in flight. */
.swap-stable.htmx-swapping { opacity: 0.4; transition: opacity 100ms ease; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------------------------------------------------------------------------
 * Tables — used by billing history, usage, and the admin screens.
 * ------------------------------------------------------------------------ */
.table-sky { width: 100%; border-collapse: collapse; }
.table-sky th {
  text-align: left;
  padding: var(--sp-2) var(--sp-3);
  font: 500 10px/1 var(--font-mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--sky-muted);
  border-bottom: 1px solid var(--sky-edge);
  white-space: nowrap;
}
.table-sky td {
  padding: var(--sp-3);
  border-bottom: 1px solid var(--sky-edge);
  font-size: 14.5px;
  vertical-align: top;
}
.table-sky td.num, .table-sky th.num { text-align: right; }
.table-wrap { overflow-x: auto; }

/* ---------------------------------------------------------------------------
 * Upload target — the one place with a drop shadow, per the design.
 * ------------------------------------------------------------------------ */
.dropzone {
  border: 2px dashed var(--sky-edge);
  border-radius: var(--r-panel);
  background: var(--sky-panel);
  box-shadow: var(--shadow-lift);
  padding: var(--sp-6) var(--sp-5);
  text-align: center;
  transition: border-color 140ms ease, background 140ms ease;
}
.dropzone.is-over {
  border-color: var(--sky-cyan);
  background: color-mix(in srgb, var(--sky-cyan) 8%, var(--sky-panel));
}

/* Empty states get the same panel treatment but no shadow — they are a place
 * where nothing is happening, not an invitation to drop. */
.empty {
  padding: var(--sp-6) var(--sp-4);
  text-align: center;
  color: var(--sky-muted);
}
.empty__title { font: 600 22px/1.25 var(--font-ui); color: var(--sky-bright); margin-bottom: var(--sp-2); }

/* The media viewer deliberately ignores the selected palette. The black field
 * lets the file, rather than the application chrome, own the screen. */
.viewer { min-height: calc(100vh - 100px); background: #050709; padding: var(--sp-4); border-radius: var(--r-panel); }
.viewer__media { display: block; max-width: 100%; max-height: 72vh; margin: auto; border-radius: var(--r-control); }
.viewer__audio { width: min(720px, 100%); margin: auto; }
.viewer__frame { width: 100%; height: 72vh; border: 0; background: #fff; border-radius: var(--r-control); }

/* ---------------------------------------------------------------------------
 * Usage charts (screen 8c).
 *
 * Server-rendered SVG rather than a charting library: there is no Node in this
 * build, and six bars with a cap line do not need one. The bars use the same
 * cyan as the meters, because a reader who has learned what that colour means
 * on the dashboard should not have to learn it again here.
 *
 * The <svg> stretches to its container with preserveAspectRatio="none", so the
 * bar geometry is computed in a fixed 600×180 space and the browser does the
 * responsive part. Labels live outside the SVG in a flex row aligned to the
 * same column count — text inside a non-uniformly scaled SVG distorts.
 * ------------------------------------------------------------------------ */
.chart {
  display: block;
  width: 100%;
  height: 180px;
  overflow: visible;
}

.chart__bar {
  fill: var(--sky-cyan-fill);
  /* Rounded tops only would need a path; a small uniform radius reads the same
   * at this size and stays one rect. */
  rx: 2;
}

/* The allowance line. Dashed so it cannot be mistaken for a bar, and drawn
 * under them so a month that ran past it visibly crosses the line rather than
 * stopping at it. */
.chart__cap {
  stroke: var(--sky-warn);
  stroke-width: 1;
  stroke-dasharray: 4 4;
  vector-effect: non-scaling-stroke;
}

.chart__labels {
  display: flex;
  justify-content: space-around;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
  text-align: center;
}
.chart__labels > * { flex: 1 1 0; }

/* ---------------------------------------------------------------------------
 * Consolidated workspace interactions
 * ------------------------------------------------------------------------ */
.row--center { justify-content: center; }
.row--end { justify-content: flex-end; }

.quota-summary {
  padding: var(--sp-3);
  border: 1px solid var(--sky-edge);
  border-radius: var(--r-control);
  color: var(--sky-bright);
  text-decoration: none;
}
.quota-summary:hover { background: var(--sky-panel-2); color: var(--sky-bright); }
.upload-primary { width: 100%; }

.files-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: var(--sp-4);
}
.files-header__title { min-width: 0; }
.files-header__actions,
.file-detail__actions,
.files-toolbar__row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.current-folder-items,
.largest-files-list,
.shared-list__body { padding: var(--sp-2); }
.files-empty-drop { box-shadow: none; border: 0; }

.files-toolbar__row { align-items: stretch; }
.files-search { flex: 1; min-width: 0; }
.files-search .input-sky { height: 100%; }
.files-filter-button { min-width: 128px; }
.filter-chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.filter-chip,
.filter-tab {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid var(--sky-edge);
  border-radius: var(--r-pill);
  color: var(--sky-muted);
  text-decoration: none;
  font: 600 13px/1.3 var(--font-ui);
}
.filter-chip:hover,
.filter-tab:hover,
.filter-tab[aria-current="page"] {
  color: var(--sky-bright);
  border-color: var(--sky-cyan);
  background: color-mix(in srgb, var(--sky-cyan) 8%, transparent);
}
.filter-tabs { display: flex; flex-wrap: wrap; gap: var(--sp-2); }

.drag-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 80;
  padding: var(--sp-5);
  background: color-mix(in srgb, var(--sky-deep) 78%, transparent);
  pointer-events: none;
}
.drag-overlay.is-visible { display: grid; place-items: center; }
.drag-overlay__content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-2);
  width: min(620px, 100%);
  padding: var(--sp-6);
  border: 2px dashed var(--sky-cyan);
  border-radius: var(--r-panel);
  background: var(--sky-panel);
  box-shadow: var(--shadow-lift);
}

/* Native dialog supplies focus trapping and Escape semantics. The desktop
 * upload surface is a bottom drawer; compact task dialogs stay small. */
.sheet,
.confirm-dialog {
  color: var(--sky-bright);
  border: 1px solid var(--sky-edge);
  background: var(--sky-panel);
  box-shadow: var(--shadow-lift);
}
.sheet::backdrop,
.confirm-dialog::backdrop { background: rgba(3, 7, 11, 0.72); }
.sheet {
  width: min(760px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 32px));
  padding: 0;
  border-radius: var(--r-panel);
}
.upload-sheet {
  width: min(920px, 100vw);
  max-height: 72vh;
  margin: auto auto 0;
  border-radius: var(--r-panel) var(--r-panel) 0 0;
  border-bottom: 0;
}
.compact-sheet { width: min(520px, calc(100vw - 32px)); }
.sheet__surface {
  display: flex;
  flex-direction: column;
  max-height: inherit;
  background: var(--sky-panel);
}
.sheet__head,
.sheet__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4);
  background: var(--sky-panel);
}
.sheet__head { border-bottom: 1px solid var(--sky-edge); }
.sheet__body { min-height: 0; overflow-y: auto; padding: var(--sp-4); }
.sheet__actions {
  justify-content: flex-end;
  border-top: 1px solid var(--sky-edge);
  padding-bottom: calc(var(--sp-4) + env(safe-area-inset-bottom));
}
.sheet__sticky-action {
  position: sticky;
  bottom: calc(-1 * var(--sp-4));
  display: flex;
  justify-content: flex-end;
  margin: 0 calc(-1 * var(--sp-4)) calc(-1 * var(--sp-4));
  padding: var(--sp-4);
  border-top: 1px solid var(--sky-edge);
  background: var(--sky-panel);
}
.upload-queue {
  min-height: 84px;
  border: 1px solid var(--sky-edge);
  border-radius: var(--r-control);
}
.confirm-dialog {
  width: min(460px, calc(100vw - 32px));
  padding: var(--sp-5);
  border-radius: var(--r-panel);
}

.filerow { grid-template-columns: minmax(0, 1fr) auto auto auto auto; }
.filerow__actions { display: flex; align-items: center; gap: var(--sp-2); }
.filerow__quick { opacity: 0; pointer-events: none; }
.filerow:hover .filerow__quick,
.filerow:focus-within .filerow__quick { opacity: 1; pointer-events: auto; }

.action-menu { position: relative; }
.action-menu > summary { list-style: none; }
.action-menu > summary::-webkit-details-marker { display: none; }
.action-menu__panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  display: grid;
  min-width: 150px;
  padding: 6px;
  border: 1px solid var(--sky-edge);
  border-radius: var(--r-control);
  background: var(--sky-panel);
  box-shadow: var(--shadow-lift);
}
.action-menu__panel button,
.action-menu__panel a {
  min-height: 40px;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--sky-bright);
  text-align: left;
  text-decoration: none;
  font: 600 14px/1.3 var(--font-ui);
  cursor: pointer;
}
.action-menu__panel button:hover,
.action-menu__panel button:focus-visible,
.action-menu__panel a:hover,
.action-menu__panel a:focus-visible { background: var(--sky-panel-2); }
.action-menu__touch { display: none; }

.file-detail { max-width: 980px; }
.file-detail__preview { min-height: 240px; }
.file-detail__title h1 { overflow-wrap: anywhere; }
.file-detail__title-row { display: flex; align-items: flex-start; gap: var(--sp-3); }
.file-detail__meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--sp-3) var(--sp-4);
}
.file-detail__meta > div { display: flex; flex-direction: column; gap: var(--sp-1); min-width: 0; }
.file-detail__meta dt { color: var(--sky-muted); }
.file-detail__meta dd { margin: 0; color: var(--sky-bright); overflow-wrap: anywhere; }
.inline-rename { display: flex; gap: var(--sp-2); align-items: center; }
.inline-rename .input-sky { flex: 1; }
.disclosure,
.danger-disclosure {
  border: 1px solid var(--sky-edge);
  border-radius: var(--r-control);
  padding: var(--sp-3);
}
.disclosure > summary,
.danger-disclosure > summary { cursor: pointer; }
.disclosure__body { margin-top: var(--sp-4); }
.share-summary {
  padding: var(--sp-3);
  border-left: 3px solid var(--sky-cyan);
  background: color-mix(in srgb, var(--sky-cyan) 8%, transparent);
}

.target-picker { display: grid; gap: var(--sp-2); }
.target-picker__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  min-height: 48px;
  padding: var(--sp-3);
  border: 1px solid var(--sky-edge);
  border-radius: var(--r-control);
  background: transparent;
  color: var(--sky-bright);
  text-align: left;
  cursor: pointer;
}
.target-picker__row:hover,
.target-picker__row:focus-visible { border-color: var(--sky-cyan); background: var(--sky-panel-2); }
.shared-list__archive-title { margin: var(--sp-5) var(--sp-3) var(--sp-2); }

.plan-page { max-width: 1060px; }
.plan-nav { display: flex; gap: var(--sp-2); position: sticky; top: 0; z-index: 20; padding: var(--sp-2) 0; background: var(--sky-deep); }
.plan-nav a { min-height: 44px; padding: 10px 14px; color: var(--sky-muted); text-decoration: none; }
.plan-nav a:hover { color: var(--sky-bright); }
.plan-section { scroll-margin-top: 64px; }
.plan-section__summary { display: none; }
.plan-section__content { padding-top: var(--sp-2); }
.charges-table { min-width: 680px; }
.charges-table th.num,
.charges-table td.num { text-align: right; }
.charges-pager { border-top: 1px solid var(--sky-edge); border-bottom: 0; }

.account-page { max-width: 760px; }
.account-summary { cursor: pointer; list-style: none; }
.account-summary::-webkit-details-marker { display: none; }
.account-summary .btn { pointer-events: none; }
.session-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  min-height: 52px;
}
.session-row--current { padding-bottom: var(--sp-3); border-bottom: 1px solid var(--sky-edge); }

@media (max-width: 768px) {
  html, body { max-width: 100%; overflow-x: hidden; }
  .btn { min-height: 44px; }
  .shell__main { min-width: 0; padding-inline: var(--sp-3); }
  .files-header { grid-template-columns: 1fr; align-items: start; }
  .files-header__actions { width: 100%; }
  .files-header__actions .btn { min-height: 44px; }
  .files-header__actions .btn:first-child { flex: 1; }
  .files-toolbar__row { display: grid; grid-template-columns: 1fr auto; }
  .files-search { grid-column: 1 / -1; width: 100%; }
  .files-search .input-sky { min-height: 44px; }
  .files-filter-button { grid-column: 2; min-width: 132px; min-height: 44px; }
  .filter-chip, .filter-tab { min-height: 44px; }
  .filter-sort-grid { grid-template-columns: 1fr; }

  .filerow {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    min-width: 0;
    padding: var(--sp-3);
  }
  .filerow__name { white-space: normal; overflow-wrap: anywhere; }
  .filerow__size { grid-column: 1; grid-row: 2; }
  .filerow__date { display: inline; grid-column: 1; grid-row: 3; }
  .filerow > .pill { grid-column: 2; grid-row: 1; }
  .filerow__actions { grid-column: 1 / -1; grid-row: 4; justify-content: flex-end; }
  .filerow__quick { display: none; }
  .action-menu > summary { min-width: 44px; min-height: 44px; }
  .action-menu__panel button,
  .action-menu__panel a { min-height: 44px; }
  .action-menu__panel .action-menu__touch { display: flex; align-items: center; }
  .filerow__progress { grid-row: 5; }

  .sheet,
  .upload-sheet,
  .compact-sheet,
  .target-sheet,
  .share-sheet {
    inset: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border: 0;
    border-radius: 0;
  }
  .sheet__surface { height: 100%; max-height: 100%; }
  .sheet__body { flex: 1; }
  .sheet__head .btn,
  .sheet__actions .btn,
  .sheet__sticky-action .btn { min-height: 44px; }
  .sheet__sticky-action .btn { width: 100%; }

  .file-detail__preview { min-height: 180px; margin-inline: calc(-1 * var(--sp-3)); border-radius: 0; }
  .file-detail__actions { display: grid; grid-template-columns: 1fr 1fr; }
  .file-detail__actions .btn { min-height: 44px; }
  .file-detail__meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .inline-rename { flex-wrap: wrap; }

  .plan-nav { display: none; }
  .plan-section {
    border: 1px solid var(--sky-edge);
    border-radius: var(--r-panel);
    background: var(--sky-panel);
  }
  .plan-section__summary { display: block; padding: var(--sp-4); cursor: pointer; }
  .plan-section__content { padding: 0 var(--sp-3) var(--sp-3); }
  .quota-grid { grid-template-columns: 1fr; }
  .account-summary { align-items: center; }
  .session-row { align-items: flex-start; }
}
