:root {
  color-scheme: light;
  --bg: #f6f8f6;
  --panel: #ffffff;
  --ink: #181716;
  --muted: #626a66;
  --line: #dbe2dc;
  --accent: #136f63;
  --accent-strong: #0c544b;
  --warm: #8f6d13;
  --danger: #b42318;
  --shadow: 0 18px 50px rgb(30 38 35 / 12%);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button,
.link-button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.primary,
.secondary,
.ghost,
.icon-button {
  min-height: 42px;
  padding: 0 16px;
}

.primary,
.link-button.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: white;
}

.primary:hover {
  background: var(--accent-strong);
}

.secondary {
  background: #e6efeb;
  color: #2c2925;
}

.secondary.danger {
  color: var(--danger);
}

.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}

.full {
  width: 100%;
}

.icon-button {
  width: 42px;
  padding: 0;
  border-radius: 50%;
  background: #e8eeea;
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
}

.muted {
  color: var(--muted);
  margin: 0;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--warm);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.error {
  margin: 0;
  color: var(--danger);
  font-weight: 700;
}

.auth-shell,
.public-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.public-shell.wide {
  align-items: start;
  padding-top: 48px;
}

.auth-panel,
.public-file {
  width: min(100%, 520px);
  padding: 32px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.public-folder {
  width: min(100%, 960px);
}

.auth-panel h1,
.public-file h1 {
  margin: 0 0 8px;
  font-size: clamp(30px, 6vw, 48px);
  line-height: 1.02;
}

.stack {
  display: grid;
  gap: 16px;
}

.auth-panel .stack,
.unlock-form {
  margin-top: 28px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px;
  background: #27231e;
  color: white;
}

.sidebar .muted,
.sidebar .eyebrow {
  color: #d5c5af;
}

.sidebar .ghost {
  border-color: rgb(255 255 255 / 58%);
  color: #f8f2e9;
}

.sidebar .ghost:hover {
  background: rgb(255 255 255 / 12%);
}

.sidebar h1 {
  margin: 0;
  font-size: 26px;
}

.folder-list {
  display: grid;
  gap: 8px;
  overflow: auto;
}

.sidebar-actions {
  display: grid;
  gap: 8px;
}

.folder-button {
  min-height: 40px;
  padding: 0 12px;
  background: transparent;
  color: #f8f2e9;
  text-align: left;
  border: 1px solid rgb(255 255 255 / 14%);
}

.folder-button.active,
.folder-button:hover {
  background: rgb(255 255 255 / 12%);
}

.workspace {
  min-width: 0;
  padding: 28px;
  display: grid;
  align-content: start;
  gap: 24px;
}

.topbar,
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

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

.topbar h2,
.section-head h3 {
  margin: 4px 0 0;
}

.upload-zone {
  padding: 20px;
  background: var(--panel);
  border: 1px dashed #bfae99;
  border-radius: 8px;
}

.upload-zone.dragging {
  border-color: var(--accent);
  background: #f1faf6;
}

.upload-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto;
  gap: 12px;
  align-items: end;
}

.file-picker input {
  display: none;
}

.file-picker span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 8px;
  background: #e6efeb;
  color: var(--ink);
  cursor: pointer;
}

progress {
  width: 100%;
  margin-top: 12px;
}

.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}

.filters {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 260px);
  gap: 12px;
  margin: 12px 0 16px;
}

.file-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.thumb {
  width: 100%;
  aspect-ratio: 16 / 10;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  border-radius: 8px;
  background: #101615;
  border: 1px solid var(--line);
}

.thumb img,
.thumb video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.public-thumb {
  width: 132px;
}

.file-main {
  min-width: 0;
}

.file-name {
  margin: 0 0 6px;
  overflow-wrap: anywhere;
  font-weight: 800;
}

.file-meta {
  color: var(--muted);
  font-size: 13px;
}

.file-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.file-actions a,
.file-actions button {
  min-height: 36px;
  padding: 0 10px;
  border-radius: 8px;
  background: #edf3ef;
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
  font-weight: 800;
}

.file-actions .danger {
  color: var(--danger);
}

.file-select {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.file-select input {
  width: 18px;
  min-height: 18px;
  margin-top: 2px;
}

.empty {
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--panel);
}

.modal {
  width: min(920px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.modal.narrow {
  width: min(520px, calc(100vw - 28px));
}

.modal::backdrop {
  background: rgb(22 19 16 / 58%);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.modal-head h3 {
  margin: 0;
  overflow-wrap: anywhere;
}

.preview-body,
.share-result,
#shareForm,
#folderShareForm,
#editForm,
#passwordForm,
.share-list {
  padding: 16px;
}

.preview-body {
  min-height: 240px;
}

.preview-body img,
.preview-body video,
.public-preview img,
.public-preview video {
  display: block;
  width: 100%;
  max-height: 72vh;
  object-fit: contain;
  background: #111;
}

.preview-body audio,
.public-preview audio {
  width: 100%;
}

.preview-body iframe,
.public-preview iframe {
  width: 100%;
  min-height: 68vh;
  border: 1px solid var(--line);
}

.share-result {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.share-list {
  display: grid;
  gap: 8px;
}

.share-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.share-row a {
  color: var(--accent-strong);
  overflow-wrap: anywhere;
}

.public-preview {
  margin: 24px 0;
}

.public-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 24px 0 12px;
}

.public-upload {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.public-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.public-file-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.public-file-row.no-thumb {
  grid-template-columns: minmax(0, 1fr) auto;
}

.public-file-row strong {
  overflow-wrap: anywhere;
}

.public-file-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.public-file-actions a,
.public-file-actions button {
  min-height: 36px;
  padding: 0 10px;
  background: #edf3ef;
  color: var(--ink);
  text-decoration: none;
}

.public-file-actions .danger {
  color: var(--danger);
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .workspace {
    padding: 18px;
  }

  .upload-form,
  .share-result {
    grid-template-columns: 1fr;
  }

  .topbar,
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions,
  .filters {
    width: 100%;
    grid-template-columns: 1fr;
  }

  .top-actions button {
    flex: 1;
  }

  .public-file-row {
    grid-template-columns: 1fr;
  }

  .public-thumb {
    width: 100%;
  }

  .public-file-actions {
    justify-content: flex-start;
  }
}
