:root {
  --paper: #ffffff;
  --paper-warm: #f6f4f1;
  --paper-soft: #faf9f7;
  --ink: #181817;
  --ink-muted: #77736f;
  --line: #e6e2dd;
  --line-strong: #cfc9c2;
  --accent: #e64b13;
  --accent-soft: #fff3ec;
  --danger: #b42318;
  --success: #16794b;
  --radius: 9px;
  --header-height: 68px;
  --font: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { color-scheme: light; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select { font: inherit; }

button { color: inherit; }

button,
[tabindex] { -webkit-tap-highlight-color: transparent; }

button:focus-visible,
input:focus-visible,
[tabindex]:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

[hidden] { display: none !important; }

.site-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 40px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.wordmark {
  color: var(--ink);
  font-size: 20px;
  font-weight: 750;
  letter-spacing: -0.04em;
  text-decoration: none;
}

.wordmark-button {
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.text-button,
.quiet-button,
.icon-button {
  border: 0;
  background: transparent;
  cursor: pointer;
}

.text-button {
  padding: 8px 0;
  color: var(--ink-muted);
}

.text-button:hover { color: var(--ink); }

.primary-button,
.quiet-button {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0 18px;
  border-radius: var(--radius);
  white-space: nowrap;
}

.primary-button {
  border: 1px solid var(--ink);
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  font-weight: 620;
}

.primary-button:hover { background: #2a2a27; }
.primary-button:disabled { opacity: 0.55; cursor: wait; }

.quiet-button {
  padding-inline: 10px;
  color: #292826;
}

.quiet-button:hover { background: var(--paper-soft); }

.primary-button .ti,
.quiet-button .ti { font-size: 21px; }

.icon-button {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  font-size: 21px;
}

.icon-button:hover { background: rgba(24, 24, 23, 0.06); }

/* Friendly fallback */
.landing {
  min-height: 100vh;
  background: var(--paper);
}

.landing-content {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  text-align: center;
}

.landing-icon {
  color: #8a8580;
  font-size: 48px;
}

.landing-secret {
  width: 70px;
  height: 70px;
  display: grid;
  place-items: center;
  margin: 0 0 30px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: default;
}

.landing h1 {
  margin: 0;
  font-size: clamp(34px, 5vw, 52px);
  line-height: 1.05;
  letter-spacing: -0.045em;
}

.landing-lead {
  margin: 14px 0 0;
  font-size: 19px;
  color: #3c3a37;
}

/* Auth */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(24, 24, 23, 0.48);
}

.auth-dialog {
  position: relative;
  width: min(420px, 100%);
  padding: 34px;
  border-radius: 12px;
  background: var(--paper);
}

.auth-close {
  position: absolute;
  top: 16px;
  right: 16px;
}

.eyebrow {
  margin: 0 0 9px;
  color: var(--ink-muted);
  font-size: 13px;
  font-weight: 650;
}

.auth-dialog h2,
.folder-dialog h2 {
  margin: 0;
  font-size: 25px;
  line-height: 1.2;
  letter-spacing: -0.035em;
}

.auth-note {
  margin: 11px 0 26px;
  color: var(--ink-muted);
}

label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 650;
}

input {
  width: 100%;
  height: 46px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
}

select {
  width: 100%;
  height: 46px;
  padding: 0 38px 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
}

select:focus { border-color: var(--ink); outline: none; }

input:focus { border-color: var(--ink); outline: none; }

.form-error {
  min-height: 20px;
  margin: 8px 0 10px;
  color: var(--danger);
  font-size: 13px;
}

.auth-submit { width: 100%; }

/* Main file manager */
.admin { min-height: 100vh; }

.admin-logout {
  position: fixed;
  top: 22px;
  right: 28px;
  z-index: 30;
  padding: 8px;
  border: 0;
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
}

.admin-logout:hover { color: var(--ink); }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 58%) minmax(400px, 42%);
}

.workspace {
  min-width: 0;
  padding: 42px clamp(30px, 3vw, 42px) 80px;
}

.workspace-heading h1 {
  margin: 0;
  font-size: clamp(34px, 3vw, 45px);
  line-height: 1.05;
  letter-spacing: -0.05em;
  font-weight: 650;
}

.workspace-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  padding-right: 58px;
}

.storage-usage {
  margin: 0;
  color: var(--ink-muted);
  font-size: 13px;
  white-space: nowrap;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 26px;
  margin-top: 20px;
}

.crumb {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink-muted);
  cursor: pointer;
}

.crumb-up {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 8px;
  padding: 0 10px 0 0;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-weight: 600;
}

.crumb-up:hover { color: var(--accent); }

.crumb[aria-current="page"] { color: var(--ink); }
.crumb:not([aria-current="page"]):hover { color: var(--ink); }
.crumb-separator { color: #b3aea8; }

.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 30px;
}

.dropzone {
  min-height: 100px;
  display: flex;
  align-items: center;
  gap: 18px;
  margin-top: 32px;
  padding: 22px 6px;
  border-top: 1px dashed var(--line-strong);
  border-bottom: 1px dashed var(--line-strong);
  color: var(--ink-muted);
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease;
}

.dropzone > .ti { font-size: 25px; }
.dropzone p { margin: 0; }

.dropzone-hint {
  margin-top: 4px !important;
  color: #99938d;
  font-size: 13px;
}

.dropzone:hover,
.dropzone.dragover {
  background: var(--paper-soft);
  color: var(--ink);
}

.upload-progress {
  margin-top: 16px;
  padding: 4px 0;
}

.progress-copy {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  color: var(--ink-muted);
  font-size: 13px;
}

.progress-track {
  height: 3px;
  overflow: hidden;
  background: var(--line);
}

.progress-fill {
  width: 0;
  height: 100%;
  background: var(--accent);
  transition: width 160ms linear;
}

.file-browser { margin-top: 32px; }

.list-label {
  margin: 0 0 10px;
  color: var(--ink-muted);
  font-size: 14px;
}

.file-list { border-top: 1px solid var(--line); }

.file-row {
  position: relative;
  min-height: 86px;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 18px;
  padding: 11px 8px 11px 18px;
  border-bottom: 1px solid var(--line);
  cursor: default;
}

.file-row::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: transparent;
}

.file-row:hover { background: var(--paper-soft); }

.file-row.selected { background: var(--accent-soft); }
.file-row.selected::before { background: var(--accent); }

.item-visual {
  width: 58px;
  height: 54px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 7px;
  color: #292826;
  font-size: 34px;
}

.item-visual.media { background: #272725; color: #fff; }

.item-visual img,
.item-visual video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.item-copy {
  min-width: 0;
}

.item-name {
  display: block;
  max-width: 100%;
  overflow: hidden;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 610;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

button.item-name { cursor: pointer; }
button.item-name:hover { color: var(--accent); }

.item-meta {
  margin: 4px 0 0;
  overflow: hidden;
  color: var(--ink-muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-action {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #282725;
  cursor: pointer;
  font-size: 21px;
}

.row-action:hover { background: rgba(24, 24, 23, 0.07); }
.row-action.copied { color: var(--success); }

.row-menu { position: relative; }
.row-menu summary { list-style: none; }
.row-menu summary::-webkit-details-marker { display: none; }

.row-menu-popover {
  position: absolute;
  top: 44px;
  right: 0;
  z-index: 20;
  min-width: 155px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
}

.row-menu-popover button,
.row-menu-popover a {
  width: 100%;
  min-height: 36px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 9px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.row-menu-popover button:hover,
.row-menu-popover a:hover { background: var(--paper-soft); }
.row-menu-popover .danger { color: var(--danger); }

.empty-list {
  padding: 50px 10px;
  color: var(--ink-muted);
  text-align: center;
}

.empty-list .ti {
  display: block;
  margin-bottom: 10px;
  font-size: 32px;
}

/* Selected item */
.detail-panel {
  min-width: 0;
  padding: 50px clamp(28px, 3vw, 40px) 70px;
  border-left: 1px solid var(--line);
  background: var(--paper-warm);
}

.detail-empty {
  min-height: 55vh;
  display: grid;
  place-content: center;
  justify-items: center;
  color: #96908a;
  text-align: center;
}

.detail-empty .ti { margin-bottom: 14px; font-size: 34px; }
.detail-empty p { max-width: 270px; margin: 0; }

.detail-title {
  margin: 0 0 20px;
  overflow: hidden;
  font-size: clamp(24px, 2vw, 30px);
  line-height: 1.18;
  letter-spacing: -0.035em;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-preview {
  aspect-ratio: 16 / 9;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 12px;
  background: #171716;
  color: #fff;
}

.detail-preview img,
.detail-preview video,
.detail-preview iframe {
  width: 100%;
  height: 100%;
  border: 0;
  object-fit: contain;
}

.detail-preview .ti { font-size: 46px; }

.detail-meta {
  margin: 18px 0 0;
  color: var(--ink-muted);
}

.share-block { margin-top: 40px; }

.share-label {
  display: block;
  margin-bottom: 10px;
  color: var(--ink-muted);
  font-size: 13px;
  font-weight: 600;
}

.share-control { display: block; }

.share-control input {
  height: 52px;
  border-radius: var(--radius);
  background: var(--paper);
}

.detail-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}

.detail-actions .primary-button {
  border-color: var(--accent);
  background: var(--accent);
}

.detail-actions .primary-button:hover { background: #cc3e0d; }

.detail-actions button.copied,
.public-file-footer .primary-button.copied,
.public-heading .primary-button.copied {
  border-color: var(--success);
  background: var(--success);
}

.detail-actions button.copied:hover,
.public-file-footer .primary-button.copied:hover,
.public-heading .primary-button.copied:hover { background: var(--success); }

.detail-open {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 46px;
  margin-top: 0;
  padding: 0 10px;
  color: var(--ink);
  text-decoration: none;
}

.detail-open:hover { color: var(--accent); }

/* Dialog and feedback */
.folder-dialog {
  width: min(430px, calc(100% - 32px));
  padding: 0;
  border: 0;
  border-radius: 12px;
}

.folder-dialog::backdrop { background: rgba(24, 24, 23, 0.48); }
.folder-dialog form { padding: 30px; }

.dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 26px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
}

.move-file-name {
  margin: -10px 0 22px;
  overflow: hidden;
  color: var(--ink-muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 200;
  max-width: calc(100vw - 32px);
  padding: 11px 16px;
  border-radius: var(--radius);
  background: var(--ink);
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 150ms ease, transform 150ms ease;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

.github-link {
  position: fixed;
  left: 18px;
  bottom: 18px;
  z-index: 80;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink-muted);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}

.github-link .ti { font-size: 17px; }

.github-link:hover {
  background: var(--paper);
  color: var(--ink);
}

/* Public viewer */
.public-page { min-height: 100vh; background: var(--paper-soft); }

.public-content {
  width: min(1280px, calc(100% - 64px));
  margin: 0 auto;
  padding: 52px 0 80px;
}

.public-file-heading {
  min-width: 0;
  margin-bottom: 24px;
}

.public-file-heading h1 {
  margin: 0;
  overflow: hidden;
  font-size: clamp(30px, 4vw, 48px);
  font-weight: 650;
  line-height: 1.08;
  letter-spacing: -0.045em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.public-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 30px;
}

.public-heading h1 {
  margin: 0;
  font-size: clamp(30px, 4vw, 44px);
  line-height: 1.12;
  letter-spacing: -0.045em;
}

.public-subtitle { margin: 9px 0 0; color: var(--ink-muted); }

.public-media {
  display: grid;
  place-items: center;
  min-height: 320px;
  overflow: hidden;
  border-radius: 14px;
  background: #151514;
  color: #fff;
}

.public-media.is-video {
  aspect-ratio: 16 / 9;
  min-height: 0;
}

.public-media.is-video video {
  width: 100%;
  height: 100%;
  max-height: none;
}

.public-media img,
.public-media video,
.public-media iframe {
  display: block;
  max-width: 100%;
  width: 100%;
  max-height: 72vh;
  border: 0;
  object-fit: contain;
}

.public-media iframe { height: 72vh; }

.public-file-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding-top: 18px;
}

.public-file-footer .public-subtitle { margin: 0; }

.public-file-footer .primary-button {
  border-color: var(--accent);
  background: var(--accent);
}

.public-file-footer .primary-button:hover { background: #cc3e0d; }

.public-list { border-top: 1px solid var(--line); background: var(--paper); }

.public-row {
  min-height: 76px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 15px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
}

.public-row > .ti { font-size: 27px; }
.public-row a { color: var(--ink); font-weight: 600; text-decoration: none; }
.public-row a:hover { color: var(--accent); }
.public-row p { margin: 3px 0 0; color: var(--ink-muted); font-size: 13px; }

.public-error {
  min-height: 100vh;
  display: grid;
  place-content: center;
  padding: 40px 24px 100px;
  text-align: center;
}

.public-error .ti { margin-bottom: 18px; color: var(--ink-muted); font-size: 45px; }
.public-error h1 { margin: 0; font-size: 38px; letter-spacing: -0.04em; }
.public-error p { max-width: 420px; margin: 12px auto 0; color: var(--ink-muted); }

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .detail-panel {
    border-top: 1px solid var(--line);
    border-left: 0;
  }
  .detail-empty { min-height: 220px; }
}

@media (max-width: 620px) {
  :root { --header-height: 60px; }
  .site-header { padding-inline: 20px; }
  .workspace { padding: 32px 20px 60px; }
  .workspace-title-row { padding-right: 48px; }
  .detail-panel { padding: 34px 20px 50px; }
  .toolbar { align-items: stretch; }
  .toolbar .primary-button { width: 100%; }
  .quiet-button { min-height: 40px; }
  .dropzone { margin-top: 22px; }
  .file-row {
    grid-template-columns: 48px minmax(0, 1fr) auto auto;
    gap: 10px;
    padding-left: 8px;
  }
  .item-visual { width: 48px; height: 46px; font-size: 29px; }
  .detail-actions { align-items: stretch; flex-direction: column; }
  .detail-actions .primary-button,
  .detail-actions .detail-open { width: 100%; justify-content: center; }
  .public-content { width: min(100% - 32px, 1060px); padding-top: 34px; }
  .public-heading { display: block; }
  .public-heading .primary-button { margin-top: 18px; }
  .public-file-footer { align-items: stretch; flex-direction: column; }
  .public-file-footer .primary-button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
