:root {
  --bg: #f8f8f7;
  --surface: #ffffff;
  --surface-subtle: #fbfbfa;
  --surface-warm: #fff1ef;
  --fg: #171717;
  --fg-2: #3f3f46;
  --muted: #71717a;
  --border: #e4e4e7;
  --border-soft: #f1f1f2;
  --accent: #f03e2f;
  --accent-border: #ffd6d1;
  --accent-hover: #d93628;
  --accent-on: #ffffff;
  --success: #16794b;
  --success-border: #a7e8c7;
  --success-bg: #ecfdf3;
  --danger: #dc2626;
  --danger-border: #fecaca;
  --danger-bg: #fff1ef;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-pill: 9999px;
  --elev-ring: 0 0 0 1px var(--border);
  --elev-raised: 0 18px 42px rgba(23, 23, 23, 0.1);
  --focus-ring: 0 0 0 4px rgba(240, 62, 47, 0.24);
  --motion-fast: 140ms;
  --container-max: 1100px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  color: var(--fg);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  font-size: 16px;
  line-height: 1.5;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--fg);
  font-weight: 750;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: var(--accent-on);
  font-size: 12px;
  font-weight: 800;
}

.account {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.role-badge {
  padding: 7px 10px;
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-pill);
  background: var(--surface-warm);
  color: var(--accent);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.08em;
  line-height: 1;
  text-transform: uppercase;
}

.text-button {
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--fg);
  font-weight: 700;
  cursor: pointer;
}

.text-button:hover {
  border-color: var(--border);
  background: var(--surface-warm);
  color: var(--accent);
}

.page {
  width: min(var(--container-max), calc(100% - 64px));
  margin: 0 auto;
  padding: 48px 0 72px;
}

.breadcrumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
  margin-bottom: 28px;
  color: var(--muted);
  font-size: 13px;
}

.breadcrumbs a {
  border-radius: 4px;
  text-decoration: none;
}

.breadcrumbs a:hover {
  color: var(--accent);
}

.breadcrumbs strong {
  color: var(--fg-2);
  font-weight: 700;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.page h1,
.auth-card h1 {
  margin: 0;
  color: var(--fg);
  font-size: 46px;
  font-weight: 750;
  letter-spacing: -0.03em;
  line-height: 1.05;
}

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

.actions,
.dialog-actions {
  display: flex;
  gap: 12px;
}

.button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 750;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--motion-fast), border-color var(--motion-fast), color var(--motion-fast), transform var(--motion-fast);
}

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

.button.primary:hover {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.button.secondary {
  border-color: var(--border);
  background: var(--surface);
  color: var(--fg);
  box-shadow: var(--elev-ring);
}

.button.secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.button:disabled,
.icon-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.wide {
  width: 100%;
}

.file-panel {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: 0 12px 34px rgba(23, 23, 23, 0.06);
}

.table-head,
.file-row {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) 100px 160px 240px;
  align-items: center;
  gap: 16px;
}

.table-head {
  min-height: 48px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-subtle);
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.file-row {
  min-height: 70px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 14px;
  transition: background-color var(--motion-fast);
}

.file-row:last-child {
  border-bottom: 0;
}

.file-row:hover {
  background: var(--surface-warm);
}

.file-name {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.file-name a,
.file-name > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-name a {
  border-radius: 4px;
  color: var(--fg);
  font-weight: 700;
  text-decoration: none;
}

.file-name a:hover {
  color: var(--accent);
}

.file-icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: var(--accent);
}

.file-icon.file {
  color: var(--muted);
}

.file-icon svg {
  width: 20px;
  height: 20px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.75;
}

.file-size,
time {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.icon-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--fg-2);
  font-size: 12px;
  font-weight: 750;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
}

.icon-button:hover {
  border-color: var(--accent);
  background: var(--surface);
  color: var(--accent);
}

.icon-button.danger {
  color: var(--danger);
}

.icon-button.danger:hover {
  border-color: var(--danger);
  background: var(--danger-bg);
}

.empty {
  padding: 76px 20px;
  color: var(--muted);
  text-align: center;
}

.empty-icon {
  width: 36px;
  height: 36px;
  fill: none;
  stroke: var(--muted);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.5;
}

.empty h2 {
  margin: 16px 0 6px;
  color: var(--fg);
  font-size: 18px;
}

.empty p {
  margin: 0;
}

.next {
  display: block;
  padding: 16px 20px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.notice {
  margin: 0 0 18px;
  padding: 14px 16px;
  border: 1px solid var(--success-border);
  border-radius: var(--radius-md);
  background: var(--success-bg);
  color: var(--success);
  font-size: 14px;
  font-weight: 650;
}

.notice.error {
  border-color: var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger);
}

.tasks {
  position: relative;
}

.tasks summary {
  position: relative;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-md);
  color: var(--fg-2);
  cursor: pointer;
  list-style: none;
}

.tasks summary::-webkit-details-marker {
  display: none;
}

.tasks summary:hover,
.tasks[open] summary {
  background: var(--surface-warm);
  color: var(--accent);
}

.tasks summary svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.task-count {
  position: absolute;
  top: 2px;
  right: 1px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--accent-on);
  font-size: 10px;
  font-weight: 800;
}

.task-count[hidden] {
  display: none;
}

.tasks-popover {
  position: absolute;
  z-index: 20;
  top: calc(100% + 12px);
  right: 0;
  width: min(420px, calc(100vw - 32px));
  max-height: min(560px, calc(100vh - 104px));
  overflow: auto;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--elev-raised);
}

.tasks-popover h2 {
  margin: 0 0 14px;
  font-size: 18px;
}

.task-empty {
  margin: 28px 0;
  color: var(--muted);
  text-align: center;
}

.transfer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: 8px 0;
  padding: 13px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  font-size: 14px;
}

.transfer strong {
  display: block;
}

.transfer span {
  color: var(--muted);
}

.transfer a {
  color: var(--accent);
  font-weight: 700;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
  background: var(--bg);
}

.auth-card {
  width: min(440px, 100%);
  padding: 42px 44px 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--elev-raised);
}

.auth-card.compact {
  text-align: center;
}

.wordmark {
  margin-bottom: 36px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.auth-card h1 {
  font-size: 40px;
}

.auth-card form {
  margin-top: 28px;
}

.auth-card label,
dialog label {
  display: block;
  margin: 18px 0 8px;
  color: var(--fg-2);
  font-size: 13px;
  font-weight: 750;
}

.auth-card input,
dialog input {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--fg);
  outline: none;
}

.auth-card input:focus,
dialog input:focus {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

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

.support {
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
  text-align: center;
}

dialog {
  width: min(430px, calc(100% - 32px));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--fg);
  box-shadow: var(--elev-raised);
}

dialog::backdrop {
  background: rgba(23, 23, 23, 0.38);
}

dialog form {
  padding: 28px;
}

dialog h2 {
  margin: 0;
  font-size: 20px;
}

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

.pagination {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding: 10px 20px;
  border-top: 1px solid var(--border-soft);
}

.pagination a,
.pagination strong,
.pagination span {
  min-width: 40px;
  min-height: 40px;
  display: grid;
  place-items: center;
  padding: 7px;
  border-radius: var(--radius-md);
  text-align: center;
  text-decoration: none;
}

.pagination a {
  color: var(--fg-2);
}

.pagination a:hover {
  background: var(--surface-warm);
  color: var(--accent);
}

.pagination strong {
  background: var(--accent);
  color: var(--accent-on);
}

.preview-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.preview-head h1 {
  overflow-wrap: anywhere;
}

.preview-frame,
.preview-image,
.preview-text {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: 0 12px 34px rgba(23, 23, 23, 0.06);
}

.preview-frame {
  width: 100%;
  height: calc(100vh - 220px);
  min-height: 600px;
  display: block;
}

.preview-image {
  min-height: 500px;
  display: grid;
  place-items: center;
  padding: 24px;
}

.preview-image img {
  max-width: 100%;
  max-height: calc(100vh - 240px);
  display: block;
}

.preview-text {
  min-height: 600px;
  margin: 0;
  padding: 24px;
  overflow: auto;
  overflow-wrap: anywhere;
  color: var(--fg-2);
  font: 13px/1.6 "Roboto Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
}

.preview-dialog {
  width: min(1200px, calc(100% - 40px));
  max-width: none;
  height: min(850px, calc(100% - 40px));
  padding: 0;
  overflow: hidden;
}

.preview-dialog-shell {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.preview-dialog-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.preview-dialog-bar > strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-dialog-bar > div {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.preview-dialog-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--bg);
}

.preview-embed {
  min-height: 100vh;
  padding: 0;
}

.preview-embed .preview-frame,
.preview-embed .preview-text {
  height: 100vh;
  min-height: 100vh;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.preview-embed .preview-image {
  min-height: 100vh;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

@media (max-width: 820px) {
  .topbar {
    min-height: 68px;
    padding: 0 16px;
  }

  .account > span:not(.role-badge) {
    display: none;
  }

  .page {
    width: min(100% - 32px, var(--container-max));
    padding: 32px 0 56px;
  }

  .page-head,
  .preview-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .page h1,
  .auth-card h1 {
    font-size: 36px;
  }

  .table-head {
    display: none;
  }

  .file-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    padding: 14px 16px;
  }

  .file-size,
  .file-row time {
    display: none;
  }

  .row-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
    padding-left: 36px;
  }

  .auth-shell {
    padding: 20px;
  }

  .auth-card {
    padding: 34px 26px 32px;
  }

  .preview-dialog {
    width: calc(100% - 20px);
    height: calc(100% - 20px);
  }

  .preview-dialog-bar {
    align-items: flex-start;
    flex-direction: column;
  }

  .preview-dialog-bar > div {
    width: 100%;
    flex-wrap: wrap;
  }

  .preview-dialog-bar .button {
    flex: 1 1 auto;
  }

  .preview-frame,
  .preview-text {
    min-height: 480px;
  }
}

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