/* FileX — Formulatrix house style: orange accent, quiet greys, flat cards. */

:root {
  --orange: #f89820;
  --orange-d: #e07d12;
  --orange-l: #fff4e6;
  --ink: #2f3438;
  --muted: #6b737a;
  --faint: #9aa2a9;
  --line: #e4e8ec;
  --bg: #f5f7f9;
  --card: #ffffff;
  --ok: #1a8754;
  --ok-bg: #e8f3ec;
  --warn: #b8860b;
  --warn-bg: #fff6e0;
  --danger: #c23b3b;
  --danger-bg: #fbecec;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 30, 40, .05), 0 6px 20px rgba(20, 30, 40, .05);
}

* { box-sizing: border-box; }

/* An author `display` beats the UA stylesheet's [hidden] rule, so anything
   given a display value would ignore the attribute. .btn did exactly that. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  font: 15px/1.55 "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto,
        Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--orange-d); }
a:hover { color: var(--orange); }

.accentbar { height: 3px; background: var(--orange); }

/* ── header ─────────────────────────────────────────────────────────── */

header.site {
  display: flex;
  align-items: center;
  gap: .9rem;
  padding: .65rem 1.5rem;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
header.site .logo { height: 22px; display: block; }
header.site .wordmark {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -.01em;
  padding-left: .85rem;
  border-left: 1px solid var(--line);
}
header.site .wordmark .x { color: var(--orange); }
header.site .context {
  color: var(--muted);
  font-size: .9rem;
}
header.site .session-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -.01em;
  white-space: nowrap;
}
@media (max-width: 640px) {
  header.site { flex-wrap: wrap; row-gap: .4rem; }
  header.site .spacer { flex-basis: 100%; }
}
header.site .spacer { flex: 1; }

/* ── profile menu ───────────────────────────────────────────────────── */

.profile { position: relative; }
.profile > button {
  display: flex;
  align-items: center;
  gap: .5rem;
  border: 1px solid transparent;
  background: none;
  padding: .2rem .35rem .2rem .2rem;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  color: var(--muted);
}
.profile > button:hover { border-color: var(--line); background: var(--bg); }
.profile img.avatar,
.profile .avatar-fallback {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: grid; place-items: center;
  object-fit: cover;
  background: var(--orange);
  color: #fff;
  font-weight: 700;
  font-size: .85rem;
  flex: none;
}
.profile .caret { font-size: .8rem; line-height: 1; color: var(--faint); }

.profile-menu {
  position: absolute;
  right: 0;
  top: calc(100% + .45rem);
  min-width: 230px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: .35rem;
  z-index: 40;
}
.profile-menu[hidden] { display: none; }
.profile-menu .who {
  padding: .55rem .65rem .6rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: .35rem;
}
.profile-menu .who strong { display: block; }
.profile-menu .who span { color: var(--muted); font-size: .85rem; word-break: break-all; }
.profile-menu a,
.profile-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: .45rem .65rem;
  border: 0;
  background: none;
  border-radius: 6px;
  font: inherit;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
}
.profile-menu a:hover,
.profile-menu button:hover { background: var(--bg); color: var(--ink); }
.profile-menu form { margin: 0; }
.profile-menu hr { border: 0; border-top: 1px solid var(--line); margin: .35rem 0; }

/* ── layout ─────────────────────────────────────────────────────────── */

main { max-width: 940px; margin: 1.75rem auto 3rem; padding: 0 1.5rem; }
main.wide { max-width: 1180px; }

h1 { font-size: 1.35rem; margin: 0 0 .35rem; letter-spacing: -.01em; }
h2 { font-size: 1.02rem; margin: 0 0 .6rem; }
p.lede { color: var(--muted); margin: 0 0 1.35rem; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.35rem;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 1.1rem; }
.card .card-head {
  display: flex; align-items: baseline; gap: .75rem;
  margin: -.25rem 0 1rem;
}
.card .card-head .spacer { flex: 1; }

.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: .87rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ── buttons ────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 7px;
  padding: .42rem .85rem;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { border-color: var(--faint); color: var(--ink); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary {
  background: var(--orange);
  border-color: var(--orange);
  color: #fff;
}
.btn.primary:hover { background: var(--orange-d); border-color: var(--orange-d); color: #fff; }
.btn.big { padding: .7rem 1.4rem; font-size: 1.02rem; font-weight: 600; }
.btn.link { border-color: transparent; background: none; color: var(--orange-d); padding: .3rem .4rem; }
.btn.link:hover { background: var(--orange-l); }
.btn.danger { color: var(--danger); border-color: #edc9c9; }
.btn.danger:hover { background: var(--danger-bg); border-color: var(--danger); }

/* ── the link bar shown after a transfer is created ─────────────────── */

.linkbar {
  margin-top: 1.35rem;
  text-align: left;
  border: 1px solid var(--line);
  border-left: 3px solid var(--ok);
  background: var(--ok-bg);
  border-radius: 8px;
  padding: .8rem .95rem;
}
.linkbar[hidden] { display: none; }
.linkbar-head { display: flex; align-items: baseline; gap: .6rem; margin-bottom: .5rem; }
.linkbar-row { display: flex; gap: .5rem; align-items: center; }
.linkbar-row input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: .87rem;
  padding: .42rem .6rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
}
@media (max-width: 620px) {
  .linkbar-row { flex-wrap: wrap; }
  .linkbar-row input { flex-basis: 100%; }
}

/* ── notices ────────────────────────────────────────────────────────── */

.notice {
  border: 1px solid var(--line);
  border-left: 3px solid var(--faint);
  background: #fff;
  border-radius: 8px;
  padding: .75rem .95rem;
  margin-bottom: 1.1rem;
}
.notice.ok { border-left-color: var(--ok); background: var(--ok-bg); border-color: #cfe6d8; }
.notice.warn { border-left-color: var(--warn); background: var(--warn-bg); border-color: #f0e0b8; }
.notice.error { border-left-color: var(--danger); background: var(--danger-bg); border-color: #eecdcd; }
.notice strong { display: block; margin-bottom: .15rem; }

/* ── tables & lists ─────────────────────────────────────────────────── */

table.rows { width: 100%; border-collapse: collapse; }
table.rows th, table.rows td {
  text-align: left; padding: .6rem .7rem; border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.rows th {
  font-size: .74rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); font-weight: 600;
}
table.rows tr:last-child td { border-bottom: 0; }
table.rows td.actions { text-align: right; white-space: nowrap; }

.pill {
  display: inline-block; padding: .1rem .55rem; border-radius: 999px;
  font-size: .74rem; font-weight: 600; letter-spacing: .02em;
}
.pill.live { background: var(--ok-bg); color: var(--ok); }
.pill.done { background: var(--bg); color: var(--muted); }

.empty {
  text-align: center; padding: 2.25rem 1rem; color: var(--muted);
}

/* ── folder browser ─────────────────────────────────────────────────── */

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20, 28, 36, .45);
  display: grid; place-items: center; z-index: 60; padding: 1.5rem;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: #fff; border-radius: 12px; width: min(560px, 100%);
  box-shadow: 0 20px 60px rgba(15, 25, 35, .25); overflow: hidden;
  display: flex; flex-direction: column; max-height: min(640px, 88vh);
}
.modal header { padding: 1rem 1.25rem .75rem; border-bottom: 1px solid var(--line); }
.modal header h2 { margin: 0; }
.modal .crumbs {
  padding: .55rem 1.25rem; border-bottom: 1px solid var(--line);
  font-size: .87rem; color: var(--muted); background: var(--bg);
  display: flex; flex-wrap: wrap; gap: .25rem; align-items: center;
}
.modal .crumbs button {
  border: 0; background: none; font: inherit; color: var(--orange-d);
  cursor: pointer; padding: 0 .1rem;
}
.modal .crumbs .sep { color: var(--faint); }
.modal .listing { overflow-y: auto; flex: 1; min-height: 180px; }
.modal .listing button.folder {
  display: flex; align-items: center; gap: .6rem; width: 100%;
  padding: .6rem 1.25rem; border: 0; border-bottom: 1px solid var(--line);
  background: none; font: inherit; text-align: left; cursor: pointer;
}
.modal .listing button.folder:hover { background: var(--orange-l); }
.modal .listing button.folder .chev { margin-left: auto; color: var(--faint); }
.modal .listing .empty { padding: 1.75rem 1rem; }
.modal footer {
  padding: .85rem 1.25rem; border-top: 1px solid var(--line);
  display: flex; gap: .6rem; align-items: center; background: var(--bg);
}
.modal footer .target { flex: 1; font-size: .88rem; color: var(--muted); min-width: 0; }
.modal footer .target strong { color: var(--ink); }
.modal .move-option { padding: .1rem 1.25rem .85rem; background: var(--bg); font-size: .88rem; }

/* ── public transfer page ───────────────────────────────────────────── */

.transfer-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 1.25rem;
  align-items: start;
}
@media (max-width: 860px) {
  .transfer-grid { grid-template-columns: minmax(0, 1fr); }
}

.dropzone {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 3rem 1.5rem;
  text-align: center;
  transition: border-color .12s, background .12s;
}
.dropzone.over { border-color: var(--orange); background: var(--orange-l); }
.dropzone.disabled { background: var(--bg); border-style: solid; }
.dropzone .icon { font-size: 2.4rem; line-height: 1; margin-bottom: .6rem; }
.dropzone h2 { font-size: 1.1rem; margin: 0 0 .3rem; }
.dropzone p { margin: 0 0 1.1rem; color: var(--muted); }
.dropzone input[type=file] { display: none; }

.queue { margin-top: 1.1rem; }
.queue:empty { display: none; }
.queue .item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .2rem .75rem;
  padding: .6rem .8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  margin-bottom: .5rem;
}
.queue .item .name { font-weight: 500; word-break: break-all; }
.queue .item .state { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.queue .item .state.failed { color: var(--danger); }
.queue .item .state.done { color: var(--ok); }
.queue .item .bar {
  grid-column: 1 / -1;
  height: 4px; border-radius: 999px; background: var(--line); overflow: hidden;
}
.queue .item .bar span {
  display: block; height: 100%; width: 0; background: var(--orange);
  transition: width .15s linear;
}
.queue .item.done .bar span { background: var(--ok); }
.queue .item.failed .bar span { background: var(--danger); }

.files-panel { position: sticky; top: 1.25rem; }
.files-panel ul { list-style: none; margin: 0; padding: 0; }
.files-panel li {
  display: flex; align-items: baseline; gap: .6rem;
  padding: .55rem 0; border-bottom: 1px solid var(--line);
}
.files-panel li:last-child { border-bottom: 0; }
.files-panel li a { font-weight: 500; word-break: break-all; text-decoration: none; }
.files-panel li a:hover { text-decoration: underline; }
.files-panel li .size { margin-left: auto; color: var(--faint); font-size: .82rem; white-space: nowrap; }

.countdown { font-variant-numeric: tabular-nums; }

.label-input {
  width: 100%;
  font: inherit;
  padding: .55rem .7rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
}
.label-input:focus { outline: 2px solid var(--orange); outline-offset: -1px; }
header.site .btn.link.small { font-size: .87rem; padding: .2rem .45rem; }

/* ── sign-in ────────────────────────────────────────────────────────── */

.signin { max-width: 420px; margin: 4.5rem auto; text-align: center; }
.signin .card { padding: 2.25rem 2rem; }
.signin .logo { height: 30px; margin-bottom: 1.25rem; }
.signin h1 { font-size: 1.6rem; }
.signin .tagline {
  color: var(--muted);
  font-size: 1.02rem;
  margin: .35rem 0 0;
}

.gbtn {
  display: inline-flex; align-items: center; gap: .65rem;
  border: 1px solid var(--line); background: #fff; border-radius: 7px;
  padding: .6rem 1.15rem; font-weight: 500; text-decoration: none; color: var(--ink);
  margin-top: 1.25rem;
}
.gbtn:hover { border-color: var(--faint); color: var(--ink); }
.gbtn svg { width: 18px; height: 18px; }

.toast {
  position: fixed; left: 50%; bottom: 1.75rem; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: .6rem 1.1rem; border-radius: 999px;
  box-shadow: var(--shadow); font-size: .9rem; z-index: 80;
  opacity: 0; pointer-events: none; transition: opacity .18s;
}
.toast.show { opacity: 1; }
