:root {
  color: #1a1612;
  background: #f4efe4;
  font-family: "Palatino Linotype", Palatino, "Iowan Old Style", Georgia, serif;
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: #f4efe4; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
a { color: inherit; }
:focus-visible { outline: 1px solid #1a1612; outline-offset: 2px; }
.hidden { display: none !important; }
button, input, pre, .share-card, .badge, .progress, .progress div {
  border-radius: 0;
  box-shadow: none;
}

.sheet { display: flex; align-items: stretch; min-height: 100vh; }
.spine {
  flex: 0 0 19rem;
  width: 19rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  background: #e7dcc8;
  border-right: 4px solid #1a1612;
  padding: 1.15rem 1rem 15rem;
}
.spine-kicker {
  margin: 0;
  font-size: .72rem;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.spine-name { margin: .15rem 0 .8rem; font-size: 1.45rem; line-height: 1.1; }
.spine h1 { margin: 0 0 .35rem; font-size: 1.85rem; line-height: 1.12; font-weight: 700; overflow-wrap: anywhere; }
.spine-actions { display: flex; flex-wrap: wrap; gap: .45rem; margin: .85rem 0 .45rem; }
#summary, #mode, .progress-meta, #percent, .row-size, .row-path, .share-meta, .diagnostics, .folder-list, #folder, .search input, #shareTitle, #password {
  font-family: "Cascadia Mono", Consolas, ui-monospace, monospace;
}
#summary, #mode { margin: .2rem 0; font-size: .78rem; line-height: 1.45; }
.spine-meter {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .55rem;
  align-items: end;
  margin-top: .9rem;
  padding-top: .45rem;
  border-top: 1px solid #1a1612;
  border-bottom: 3px solid #1a1612;
}
.spine-meter-label { font-family: "Cascadia Mono", Consolas, ui-monospace, monospace; font-size: .68rem; letter-spacing: .14em; }
.spine-ticks { display: flex; align-items: end; gap: 0; list-style: none; margin: 0; padding: 0; height: 1.15rem; width: 100%; }
.spine-ticks li { flex: 1; border-left: 1px solid #1a1612; height: 45%; }
.spine-ticks li:nth-child(2n) { height: 100%; }
#downloadPanel { position: fixed; z-index: 20; bottom: 0; left: 0; width: 19rem; margin: 0; padding: .75rem 1rem max(.75rem, env(safe-area-inset-bottom)); background: #e7dcc8; border-top: 3px solid #1a1612; border-right: 4px solid #1a1612; }
#downloadPanel.hidden { display: none !important; }
#downloadTitle { margin: 0; font-size: 1.05rem; font-weight: 700; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
#downloadHint { margin: .4rem 0 0; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
#speed { font-weight: 700; }
#percent { display: block; font-size: 1.35rem; line-height: 1.2; }
.progress { height: .42rem; border: 1px solid #1a1612; background: transparent; margin: .25rem 0 .35rem; }
.progress div { height: 100%; width: 0; background: #1a1612; }
.progress-meta { display: flex; flex-wrap: wrap; gap: .35rem .7rem; font-size: .72rem; }
.small { font-size: .78rem; line-height: 1.4; }

.ledger {
  flex: 1;
  min-width: 0;
  position: relative;
  padding: .85rem 1.3rem 2.4rem 2rem;
  background: #f7f3ea;
}
.ledger::before, .ledger::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  border-left: 1px solid #1a1612;
}
.ledger::before { left: .55rem; }
.ledger::after { left: .8rem; }
.ledger-toolbar, .search { display: flex; align-items: center; gap: .45rem; }
.ledger-toolbar { justify-content: space-between; min-height: 2.5rem; border-bottom: 3px double #1a1612; margin-bottom: .2rem; }
.ledger-toolbar h2 { margin: 0; font-size: 1.15rem; font-weight: 700; }
.search { flex: 1; min-width: 0; }
input:not([type=checkbox]) {
  min-width: 0;
  background: transparent;
  border: 0;
  border-bottom: 1px solid #1a1612;
  padding: .35rem .15rem;
}
label input, .folder-pick input { width: 100%; }
.search input { flex: 1; width: auto; }
.tree { min-height: 2rem; }
.preview { margin: .4rem 0 .7rem; padding-bottom: .45rem; border-bottom: 1px solid #1a1612; }
.preview-help { margin: .5rem 0; }
.preview-bar { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
#previewTitle { min-width: 0; overflow-wrap: anywhere; margin: .3rem 0; font-size: 1.1rem; }
#previewStatus { margin: .3rem 0; }
#previewStatus:empty { display: none; }
.preview-bar button { flex-shrink: 0; }
.preview-name { border: 0; padding: 0; background: transparent; text-decoration: underline; text-underline-offset: .15em; }
.preview-open { font-size: .78rem; padding: .25rem .4rem; }
.preview-media, .preview img, .preview video { display: block; max-width: 100%; max-height: 70vh; }
.preview audio { width: 100%; }
.tree > p, .shares, .footer-note { margin: 0; }
.row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .5rem;
  min-height: 1.35rem;
  border-bottom: 3px double #b7ab96;
  padding: .08rem .1rem .08rem 0;
}
.folder-toggle, .row-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.folder-toggle { border: 0; background: transparent; padding: 0; font-weight: 700; }
.row-size, .row-path { font-size: .72rem; white-space: nowrap; }
.row-path { flex: 1 0 100%; min-width: 0; white-space: normal; overflow-wrap: anywhere; }
.folder-icon, .file-icon { width: 1rem; font-family: "Cascadia Mono", Consolas, ui-monospace, monospace; font-size: .85rem; }
.children { margin-left: .85rem; border-left: 1px solid #1a1612; padding-left: .55rem; }
.footer-note { border-top: 1px solid #1a1612; margin-top: 1rem; padding-top: .55rem; font-size: .78rem; line-height: 1.45; }
.primary, .secondary, .ghost { border: 1px solid #1a1612; background: transparent; color: #1a1612; padding: .45rem .7rem; text-decoration: none; }
.primary { background: #1a1612; color: #f4efe4; }
.ghost { border: 0; padding: 0 .15rem; background: transparent; }
.row input[type=checkbox] { width: .85rem; height: .85rem; margin: 0; padding: 0; flex: none; accent-color: #1a1612; }

.admin-sheet {
  display: grid;
  grid-template-columns: 19rem minmax(0, 1fr);
  grid-template-rows: auto auto minmax(100vh, 1fr);
  grid-template-areas:
    "kicker ledger"
    "name ledger"
    "spine ledger";
  align-items: stretch;
  background: #f7f3ea;
}
.admin-sheet > .spine-kicker { grid-area: kicker; margin: 0; }
.admin-sheet > .spine-name { grid-area: name; margin: 0; }
.admin-sheet > #login { grid-area: spine; }
#dashboard:not(.hidden) { display: contents; }
#createForm { grid-area: spine; align-self: start; position: sticky; top: 0; }
.admin-sheet .ledger { grid-area: ledger; min-height: 100vh; }
.admin-sheet > .spine-kicker,
.admin-sheet > .spine-name,
.admin-sheet > #login,
#createForm {
  background: #e7dcc8;
  border-right: 4px solid #1a1612;
  padding-left: 1rem;
  padding-right: 1rem;
}
@media (min-width: 651px) {
  .admin-sheet::before {
    content: "";
    grid-column: 1;
    grid-row: 1 / -1;
    background: #e7dcc8;
    border-right: 4px solid #1a1612;
  }
  .admin-sheet > .spine-kicker,
  .admin-sheet > .spine-name,
  .admin-sheet > #login,
  #createForm {
    background: transparent;
    border-right: 0;
    z-index: 1;
  }
}
.admin-sheet > .spine-kicker { padding-top: 1.15rem; }
.admin-sheet > #login, #createForm { padding-bottom: 1.2rem; }
#login h1, #createForm h1 { margin: .2rem 0 .7rem; font-size: 1.85rem; line-height: 1.1; }
#loginForm, #createForm { display: grid; gap: .7rem; }
label { display: grid; gap: .25rem; font-size: .92rem; }
.folder-pick { display: flex; gap: .4rem; align-items: end; }
.folder-pick input { flex: 1; }
.folder-list { max-height: 18rem; overflow: auto; border-top: 1px solid #1a1612; border-bottom: 1px solid #1a1612; font-size: .78rem; }
.source-file { display: flex; align-items: center; gap: .4rem; padding: .4rem .15rem; border-bottom: 1px solid #cfc4b0; font-size: .78rem; cursor: pointer; }
.source-file input { width: 1rem; height: 1rem; margin: 0; flex: none; accent-color: #1a1612; }
.source-file span { min-width: 0; overflow-wrap: anywhere; }
#sourceSelection { margin: 0; }
.folder-list button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1px solid #cfc4b0;
  padding: .28rem .15rem;
  font-family: "Cascadia Mono", Consolas, ui-monospace, monospace;
  font-size: .78rem;
}
.shares { display: block; }
.share-card { border: 0; border-bottom: 3px double #b7ab96; background: transparent; padding: .35rem 0 .45rem; }
.share-head { display: flex; align-items: baseline; justify-content: space-between; gap: .6rem; }
.share-head strong { font-size: 1.05rem; min-width: 0; overflow-wrap: anywhere; }
.badge { flex-shrink: 0; }
#createResult { margin: 0; overflow-wrap: anywhere; }
#listingError:empty, #adminError:empty, #createResult:empty { display: none; }
.badge { font-family: "Cascadia Mono", Consolas, ui-monospace, monospace; font-size: .68rem; border: 1px solid #1a1612; padding: .08rem .28rem; background: transparent; }
.badge.off, .error { color: #9d2c2c; }
.badge.off { border-color: #9d2c2c; background: transparent; }
.share-meta { font-size: .72rem; line-height: 1.45; margin: .2rem 0 .35rem; }
.share-actions { display: flex; flex-wrap: wrap; gap: .35rem; }
.share-actions button, .share-actions a { font-size: .78rem; padding: .28rem .45rem; }
.error { margin: .2rem 0 0; }
.diagnostics { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .72rem; margin: 0; padding: .4rem 0 0; background: transparent; border: 0; color: #1a1612; }

@media (max-width: 650px) {
  .sheet { flex-direction: column; }
  .spine {
    position: static;
    padding-bottom: 1.4rem;
    top: 0;
    z-index: 2;
    height: auto;
    width: auto;
    flex: none;
    border-right: 0;
    border-bottom: 4px solid #1a1612;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: .6rem;
    align-items: center;
  }
  .spine-kicker { grid-column: 1; }
  .spine-name { grid-column: 1; margin: 0; font-size: 1rem; }
  .spine h1 { grid-column: 1; font-size: 1.35rem; margin: 0; }
  #summary { grid-column: 1; }
  .spine-actions { grid-column: 2; grid-row: 1 / span 4; align-self: center; flex-direction: column; margin: 0; width: 8.2rem; }
  #downloadAll { min-height: 4rem; white-space: normal; }
  #changeFolder.hidden { display: none !important; }
  #mode, .spine-meter, #downloadPanel { grid-column: 1 / -1; }
  .spine-meter { margin-top: .35rem; }
  #downloadPanel { width: 100%; border-right: 0; }
  .sheet:has(#downloadPanel:not(.hidden)) { padding-bottom: 15rem; }
  #downloadPanel.hidden { display: none !important; }
  .row .ghost { min-width: 2rem; min-height: 2rem; display: inline-flex; align-items: center; justify-content: center; }
  .ledger { padding: .7rem .8rem 1.6rem 1.4rem; }
  .ledger::before { left: .35rem; }
  .ledger::after { left: .55rem; }
  .ledger-toolbar, .search { align-items: stretch; flex-wrap: wrap; }
  .search { width: 100%; }
  .search input { flex: 1; }
  .admin-sheet {
    align-content: start;
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    grid-template-areas:
      "kicker"
      "name"
      "spine"
      "ledger";
  }
  .admin-sheet > .spine-kicker,
  .admin-sheet > .spine-name,
  .admin-sheet > #login,
  #createForm { border-right: 0; }
  .admin-sheet > #login, #createForm { border-bottom: 4px solid #1a1612; }
  .admin-sheet .ledger { min-height: 0; }
  #createForm { position: static; }
}
