:root {
  color-scheme: light;
  --bg: #eef1f5;
  --panel: #ffffff;
  --panel-soft: #f7f8fa;
  --ink: #181d29;
  --muted: #717a8c;
  --line: #d9dee7;
  --red: #d00f32;
  --red-dark: #a90b28;
  --danger-soft: #fff0f2;
  --green: #0f9f6e;
  --shadow: 0 12px 35px rgba(24, 29, 41, 0.08);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(90deg, var(--red) 0 10px, transparent 10px),
    var(--bg);
}

.login-panel {
  width: min(420px, 100%);
  padding: 36px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-panel h1,
.page-heading h1,
.public-heading h1 {
  margin: 4px 0 8px;
}

.brand-logo {
  width: 46px;
  height: 46px;
  margin-right: 10px;
  object-fit: contain;
}

.brand-logo.login-logo {
  width: 68px;
  height: 68px;
  margin: 0 0 24px;
}

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

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

label {
  display: grid;
  gap: 7px;
  margin-top: 18px;
  color: #515a6c;
  font-size: 13px;
  font-weight: 600;
}

input,
select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #cfd6e2;
  border-radius: 6px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(208, 15, 50, 0.1);
}

.button,
.icon-button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-weight: 700;
}

.button {
  padding: 10px 16px;
}

.button.primary {
  color: #fff;
  background: var(--red);
}

.button.primary:hover {
  background: var(--red-dark);
}

.button.ghost {
  color: var(--ink);
  background: var(--panel);
  border-color: var(--line);
}

.button.danger {
  color: #fff;
  background: var(--red);
}

.button.danger.ghost {
  color: var(--red);
  background: var(--danger-soft);
  border-color: #f1bec7;
}

.button:disabled {
  cursor: default;
  opacity: 0.45;
}

.button.wide {
  width: 100%;
  margin-top: 20px;
}

.icon-button {
  width: 42px;
  padding: 0;
  color: var(--ink);
  background: var(--panel);
  border-color: var(--line);
  font-size: 20px;
}

.form-error {
  min-height: 18px;
  margin: 12px 0 0;
  color: var(--red);
  font-size: 13px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 0 28px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
}

.brand > div:last-child {
  display: grid;
}

.brand strong {
  font-size: 18px;
}

.brand span {
  color: var(--muted);
  font-size: 12px;
}

.top-actions,
.toolbar-actions,
.modal-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.workspace {
  width: min(1440px, calc(100% - 40px));
  margin: 0 auto;
  padding: 30px 0 60px;
}

.page-heading,
.section-title,
.library-toolbar,
.storage-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.page-heading {
  margin-bottom: 20px;
}

.page-heading h1 {
  font-size: 30px;
}

.storage-strip,
.library-panel,
.shares-panel,
.upload-queue {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.storage-strip {
  padding: 18px 20px;
}

.storage-strip > div:first-child {
  display: grid;
  gap: 3px;
  min-width: 210px;
}

.storage-track {
  flex: 1;
  height: 8px;
  overflow: hidden;
  background: #e8ebf0;
  border-radius: 4px;
}

.storage-track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--green);
  transition: width 180ms ease;
}

.storage-track span.warning {
  background: var(--red);
}

.upload-zone {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 145px;
  margin: 18px 0;
  padding: 24px;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.5);
  border: 2px dashed #c7ceda;
  border-radius: 8px;
}

.upload-zone strong {
  color: var(--ink);
}

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

.upload-queue {
  margin-bottom: 18px;
  padding: 18px;
}

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

.upload-row:first-child {
  border-top: 0;
}

.upload-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress {
  height: 7px;
  overflow: hidden;
  background: #e8ebf0;
  border-radius: 4px;
}

.progress span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--red);
}

.library-panel {
  min-height: 280px;
}

.library-toolbar {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.selection-tools {
  display: flex;
  align-items: center;
  gap: 18px;
}

.check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--ink);
  font-size: 14px;
}

.check-label input,
.media-check input {
  width: 17px;
  min-height: 17px;
  accent-color: var(--red);
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  padding: 18px;
}

.media-card {
  position: relative;
  overflow: hidden;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.media-card.selected {
  border-color: var(--red);
  box-shadow: 0 0 0 2px rgba(208, 15, 50, 0.1);
}

.media-preview {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 4 / 3;
  padding: 0;
  overflow: hidden;
  color: #fff;
  background: #1c202a;
  border: 0;
  border-radius: 0;
}

.media-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-placeholder {
  display: grid;
  place-items: center;
  width: 64px;
  height: 48px;
  border: 2px solid currentColor;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 800;
}

.media-check {
  position: absolute;
  top: 10px;
  left: 10px;
  display: grid;
  place-items: center;
  width: 31px;
  height: 31px;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 6px;
}

.media-info {
  display: grid;
  gap: 5px;
  padding: 12px;
}

.media-info strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media-info span {
  color: var(--muted);
  font-size: 12px;
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 210px;
  color: var(--muted);
}

.empty-state strong {
  color: var(--ink);
}

.shares-panel {
  margin-top: 20px;
  padding: 20px;
}

.section-title h2 {
  margin: 4px 0 0;
  font-size: 21px;
}

.shares-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.share-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  padding: 14px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.share-row.inactive {
  opacity: 0.58;
}

.share-copy {
  display: grid;
  gap: 5px;
}

.share-copy span {
  color: var(--muted);
  font-size: 12px;
}

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

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  color: #08724f;
  background: #e8fbf4;
  border: 1px solid #b9ead8;
  border-radius: 13px;
  font-size: 12px;
  font-weight: 700;
}

.status.inactive {
  color: #8a2234;
  background: #fff0f2;
  border-color: #efc1c9;
}

.modal {
  width: min(560px, calc(100% - 32px));
  padding: 24px;
  color: var(--ink);
  background: var(--panel);
  border: 0;
  border-radius: 8px;
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.24);
}

.modal.compact {
  width: min(500px, calc(100% - 32px));
}

.modal::backdrop,
.preview-modal::backdrop {
  background: rgba(18, 21, 29, 0.72);
  backdrop-filter: blur(3px);
}

.modal-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.modal-heading h2 {
  margin: 4px 0 0;
}

.modal-actions {
  justify-content: flex-end;
  margin-top: 22px;
}

.modal-copy {
  color: #515a6c;
  line-height: 1.55;
}

.preview-modal {
  width: min(1200px, calc(100% - 32px));
  height: min(860px, calc(100% - 32px));
  padding: 0;
  overflow: hidden;
  background: #11141b;
  border: 0;
  border-radius: 8px;
}

.preview-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  width: 44px;
  height: 44px;
  color: #fff;
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 6px;
  font-size: 26px;
}

#preview-content,
#public-preview-content {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
}

#preview-content img,
#public-preview-content img,
#preview-content video,
#public-preview-content video {
  max-width: 100%;
  max-height: 100%;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 50;
  max-width: min(420px, calc(100% - 44px));
  padding: 13px 16px;
  color: #fff;
  background: #181d29;
  border-radius: 6px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: 160ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  background: var(--red);
}

.public-page {
  background: #f3f5f8;
}

.public-header {
  display: flex;
  align-items: center;
  min-height: 76px;
  padding: 0 max(22px, calc((100% - 1320px) / 2));
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.public-main {
  width: min(1320px, calc(100% - 40px));
  margin: 0 auto;
  padding: 38px 0 60px;
}

.public-heading {
  margin-bottom: 24px;
}

.public-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
}

.public-item {
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(24, 29, 41, 0.05);
}

.public-media {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 260px;
  max-height: 620px;
  overflow: hidden;
  background: #11141b;
}

.public-media img,
.public-media video {
  display: block;
  width: 100%;
  max-height: 620px;
  object-fit: contain;
}

.public-item-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 14px;
}

.public-item-footer strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.download-link {
  flex: 0 0 auto;
  color: var(--red);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.public-message,
.unlock-panel {
  max-width: 520px;
  margin: 90px auto 0;
  padding: 30px;
  text-align: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.unlock-panel {
  text-align: left;
}

.public-message.error h1 {
  margin-top: 0;
}

@media (max-width: 760px) {
  .topbar {
    padding: 0 16px;
  }

  .workspace,
  .public-main {
    width: min(100% - 24px, 100%);
  }

  .page-heading,
  .library-toolbar,
  .storage-strip,
  .share-row {
    align-items: stretch;
  }

  .page-heading,
  .library-toolbar,
  .storage-strip {
    flex-direction: column;
  }

  .page-heading .button,
  .toolbar-actions {
    width: 100%;
  }

  .toolbar-actions .button {
    flex: 1;
  }

  .storage-track {
    flex: none;
    width: 100%;
  }

  .selection-tools {
    justify-content: space-between;
  }

  .media-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 12px;
  }

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

  .share-actions .button {
    flex: 1;
  }

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

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

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

  .top-actions .icon-button {
    display: none;
  }
}
