:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --text: #182230;
  --muted: #667085;
  --line: #e3e8ef;
  --line-strong: #ccd5e0;
  --primary: #1677ff;
  --primary-hover: #0867df;
  --primary-soft: #eef6ff;
  --danger: #d92d20;
  --success: #16845b;
  --radius: 14px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
}
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.app-shell {
  width: min(940px, calc(100% - 32px));
  margin: 0 auto;
  padding: 0 0 40px;
}
.topbar {
  display: flex;
  min-height: 72px;
  align-items: center;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand strong { font-size: 18px; letter-spacing: -0.02em; }
.brand span { color: var(--muted); font-size: 13px; }

.workspace-switch {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  width: min(630px, 100%);
  margin: 24px 0 14px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #edf1f5;
}
.workspace-tab {
  min-width: 0;
  padding: 9px 14px;
  border: 0;
  border-radius: 9px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  text-align: left;
}
.workspace-tab > span { display: flex; align-items: baseline; gap: 7px; min-width: 0; }
.workspace-tab strong { font-size: 13px; }
.workspace-tab small { overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.workspace-tab.active {
  color: var(--text);
  background: white;
  box-shadow: 0 1px 3px rgba(16, 24, 40, 0.1);
}

.workspace-view { animation: appear 140ms ease; }
@keyframes appear { from { opacity: 0; } }
.panel {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.03);
}
.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}
.section-heading h1, .auth-intro h1 {
  margin: 0;
  font-size: 23px;
  letter-spacing: -0.025em;
}
.section-heading h2, .files-toolbar h2, .activity-panel h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.015em;
}
.section-heading p, .auth-intro p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.45;
}
.compact-heading { margin-bottom: 16px; }
.status-badge {
  flex: 0 0 auto;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: #fafbfc;
  font-size: 11px;
  font-weight: 700;
}
.status-badge.active { border-color: #a6e3cb; color: var(--success); background: #effaf6; }

.dropzone {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  min-height: 112px;
  padding: 22px;
  align-items: center;
  border: 1px dashed #b6c2d0;
  border-radius: 12px;
  background: #fafbfd;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease;
}
.dropzone:hover, .dropzone:focus-visible, .dropzone.dragover {
  border-color: var(--primary);
  outline: 0;
  background: var(--primary-soft);
}
.dropzone.compact { min-height: 96px; }
.dropzone input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.dropzone-copy { display: grid; gap: 5px; min-width: 0; }
.dropzone-copy strong { font-size: 15px; }
.dropzone-copy span { color: var(--muted); font-size: 12px; }

.btn, .icon-btn, .link-btn, .delete-btn, .file-remove {
  border: 0;
  border-radius: 9px;
  cursor: pointer;
  font-weight: 650;
  transition: background 120ms ease, border-color 120ms ease, opacity 120ms ease;
}
.btn { min-height: 38px; padding: 8px 14px; }
.btn:disabled { cursor: not-allowed; opacity: 0.5; }
.dropzone[aria-disabled="true"] { cursor: default; opacity: 0.65; }
.file-remove:disabled { cursor: default; opacity: 0.4; }
.btn-primary { color: white; background: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary, .btn-quiet {
  border: 1px solid var(--line-strong);
  color: var(--text);
  background: white;
}
.btn-secondary:hover, .btn-quiet:hover { background: #f4f6f8; }
.btn-danger { color: var(--danger); background: #fff1f0; }
.action-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.file-list { display: grid; gap: 6px; margin-top: 10px; }
.file-pill {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  padding: 9px 11px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
}
.file-pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-pill strong { color: var(--muted); font-size: 11px; }
.file-remove { padding: 2px 5px; color: var(--muted); background: transparent; font-size: 18px; }
.file-remove:hover { color: var(--danger); }
.empty-state { padding: 10px 0; color: var(--muted); font-size: 12px; }

.transfer-status {
  margin-top: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafbfd;
}
.progress-head > div { display: flex; justify-content: space-between; gap: 15px; }
.progress-head span { font-size: 12px; font-weight: 650; }
.progress-head small { color: var(--muted); }
.progress-track { overflow: hidden; height: 5px; margin-top: 9px; border-radius: 99px; background: #e6ebf1; }
.progress-bar { width: 0; height: 100%; border-radius: inherit; background: var(--primary); transition: width 150ms linear; }

.share-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  margin-top: 16px;
  padding: 16px;
  align-items: center;
  border: 1px solid #cfe2fa;
  border-radius: 11px;
  background: #f5f9ff;
}
.share-label { display: block; margin-bottom: 7px; color: var(--muted); font-size: 11px; font-weight: 700; }
.copy-row { display: flex; gap: 7px; }
.copy-row input, .form input, .search-input {
  min-width: 0;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  outline: 0;
  color: var(--text);
  background: white;
}
.copy-row input { width: 100%; }
.copy-row input:focus, .form input:focus, .search-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.1); }
.helper-text { margin: 8px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.qr-code { width: 104px; height: 104px; border: 5px solid white; border-radius: 8px; background: white; }
.received-list { display: grid; gap: 7px; margin-top: 12px; }
.received-file { display: flex; justify-content: space-between; gap: 12px; padding: 10px; align-items: center; border: 1px solid var(--line); border-radius: 9px; }
.received-file > span { min-width: 0; overflow-wrap: anywhere; }
.received-file .link-btn { flex-shrink: 0; }

.transfer-share { margin-bottom: 12px; }
.code-card { padding: 22px; border: 1px solid #cfe2fa; border-radius: 12px; background: #f5f9ff; text-align: center; }
.transfer-code { display: block; color: var(--primary); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: clamp(36px, 8vw, 52px); font-weight: 750; letter-spacing: 0.08em; white-space: nowrap; }
.code-instructions { margin: 12px 0; color: var(--text); font-size: 13px; line-height: 1.6; overflow-wrap: anywhere; }
.code-expiry { display: flex; min-height: 38px; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
#codeCountdown { font-variant-numeric: tabular-nums; }
.share-alternatives { margin-top: 12px; }
.share-alternatives summary { padding: 8px 0; color: var(--muted); cursor: pointer; font-size: 12px; }
.share-alternatives .share-card { margin-top: 4px; }
.receive-form { max-width: 520px; padding: 12px 0; }
.receive-form > label { display: block; margin-bottom: 10px; font-weight: 650; }
.receive-row { display: flex; gap: 12px; }
.receive-row input { width: 220px; min-width: 0; padding: 12px 16px; border: 1px solid var(--line-strong); border-radius: 10px; outline: 0; color: var(--text); background: white; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 26px; letter-spacing: 0.08em; }
.receive-row input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.1); }
.receive-row input[aria-invalid="true"] { border-color: var(--danger); }
.receive-error { margin: 10px 0 0; color: var(--danger); font-size: 12px; line-height: 1.5; }
.receive-error:empty { display: none; }

.auth-panel { display: grid; grid-template-columns: 1fr 340px; gap: 36px; align-items: center; }
.auth-box { padding: 18px; border: 1px solid var(--line); border-radius: 11px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; margin-bottom: 14px; padding: 3px; border-radius: 9px; background: #eef1f5; }
.tab { padding: 8px; border: 0; border-radius: 7px; color: var(--muted); background: transparent; cursor: pointer; }
.tab.active { color: var(--text); background: white; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.1); }
.form { display: grid; gap: 12px; }
.form label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; }
.form input { width: 100%; }

#managerSection { display: grid; gap: 12px; }
.account-bar { display: flex; gap: 10px; padding: 12px 16px; align-items: center; }
.account-avatar { color: var(--success); }
.account-bar > div:nth-child(2) { display: grid; flex: 1; }
.account-bar span { color: var(--muted); font-size: 10px; }
.upload-panel, .files-panel, .activity-panel { padding: 20px; }
.files-toolbar { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 12px; align-items: center; }
.storage-summary { display: flex; flex: 1; gap: 12px; color: var(--muted); font-size: 11px; }
.toolbar-actions { display: flex; gap: 6px; }
.search-input { width: 190px; }
.icon-btn { width: 38px; border: 1px solid var(--line-strong); color: var(--text); background: white; }
.table-wrap { overflow-x: auto; }
.files-table { width: 100%; border-collapse: collapse; }
.files-table th, .files-table td { padding: 11px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.files-table th { color: var(--muted); font-size: 10px; text-transform: uppercase; }
.files-table td { max-width: 350px; font-size: 12px; }
.files-table td:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; }
.file-actions { display: flex; gap: 6px; }
.link-btn, .delete-btn { display: inline-flex; padding: 6px 9px; align-items: center; text-decoration: none; font-size: 11px; }
.link-btn { border: 1px solid var(--line-strong); color: var(--text); background: white; }
.delete-btn { color: var(--danger); background: #fff1f0; }

.activity-panel summary { display: flex; justify-content: space-between; align-items: center; cursor: pointer; }
.activity-panel summary > span { color: var(--muted); font-size: 11px; }
.activity-head { display: flex; justify-content: flex-end; margin-top: 12px; }
.activity-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin-top: 10px; }
.activity-stats > div { display: grid; gap: 3px; padding: 10px; border: 1px solid var(--line); border-radius: 9px; }
.activity-stats span { color: var(--muted); font-size: 10px; }
.activity-list { display: grid; gap: 7px; margin-top: 10px; }
.activity-item { display: flex; justify-content: space-between; gap: 15px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.activity-item > div { display: grid; gap: 2px; }
.activity-item span, .activity-item time { color: var(--muted); font-size: 10px; }

.toast {
  position: fixed;
  z-index: 20;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  margin: 0;
  padding: 11px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  opacity: 0;
  pointer-events: none;
  color: var(--text);
  background: white;
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.14);
  transform: translateY(8px);
  transition: opacity 120ms ease, transform 120ms ease;
}
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.ok { border-color: #a6e3cb; }
.toast.err { border-color: #f3b7b2; color: var(--danger); }
.hidden { display: none !important; }

@media (max-width: 680px) {
  .app-shell { width: min(100% - 20px, 940px); }
  .topbar { min-height: 58px; }
  .brand { display: grid; gap: 1px; }
  .brand strong { font-size: 16px; }
  .brand span { font-size: 11px; }
  .workspace-switch { width: 100%; margin-top: 14px; }
  .workspace-tab > span { display: grid; gap: 1px; }
  .panel { padding: 16px; border-radius: 12px; }
  .section-heading { gap: 12px; }
  .section-heading h1, .auth-intro h1 { font-size: 20px; }
  .dropzone { grid-template-columns: 1fr; min-height: 0; padding: 16px; }
  .dropzone .btn { width: 100%; }
  .share-card, .auth-panel { grid-template-columns: 1fr; }
  .qr-code { width: 90px; height: 90px; }
  .activity-stats { grid-template-columns: 1fr 1fr; }
  .files-toolbar { align-items: flex-start; }
  .storage-summary { flex-basis: 100%; order: 3; }
  .toolbar-actions { width: 100%; }
  .search-input { flex: 1; width: auto; }
  .files-table thead { display: none; }
  .files-table, .files-table tbody, .files-table tr, .files-table td { display: block; width: 100%; }
  .files-table tr { padding: 10px 0; border-bottom: 1px solid var(--line); }
  .files-table td { max-width: none; padding: 3px 0; border: 0; white-space: normal !important; }
}

@media (max-width: 420px) {
  .workspace-tab small { display: none; }
  .section-heading { display: grid; }
  .status-badge { justify-self: start; }
  .copy-row { flex-direction: column; }
  .receive-row { flex-direction: column; }
  .receive-row input { width: 100%; }
  .workspace-tab { padding: 10px 8px; }
  .action-bar .btn { flex: 1 1 auto; }
  .file-pill { grid-template-columns: minmax(0, 1fr) auto; }
  .file-pill strong { grid-column: 1; }
  .file-remove { grid-column: 2; grid-row: 1 / span 2; }
}

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