:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #667085;
  --line: #d9dee7;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --danger: #b42318;
  --soft: #eef6f4;
  --shadow: 0 16px 40px rgba(16, 24, 40, 0.10);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

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

.manager-view {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.topbar h1,
.login-panel h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.2;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.topbar-actions,
.toolbar,
.tabs,
.resize-controls {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.tabs {
  margin-bottom: 16px;
}

.tab,
.primary-button,
.secondary-button,
.ghost-button,
.icon-button {
  border-radius: 8px;
  border: 1px solid var(--line);
  min-height: 40px;
  padding: 0 14px;
  background: #fff;
  color: var(--ink);
}

.tab.active,
.primary-button {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.secondary-button {
  background: var(--soft);
  border-color: #b8ddd6;
  color: var(--accent-strong);
}

.ghost-button {
  background: transparent;
}

.icon-button {
  width: 40px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  font-size: 20px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 18px;
  align-items: start;
}

.upload-panel,
.library-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.06);
  padding: 18px;
}

.upload-panel {
  display: grid;
  gap: 16px;
  position: sticky;
  top: 16px;
}

.upload-panel h2 {
  margin: 0;
  font-size: 18px;
}

.muted,
.message,
.status-line,
.upload-meta {
  color: var(--muted);
  font-size: 13px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: #344054;
  font-size: 13px;
  font-weight: 650;
}

.field input,
.field select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  min-height: 40px;
  padding: 8px 10px;
  color: var(--ink);
}

.prefix-field {
  min-width: min(420px, 100%);
  flex: 1;
}

.drop-zone {
  min-height: 170px;
  border: 1px dashed #98a2b3;
  border-radius: 8px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 22px;
  background: #fbfcfe;
}

.drop-zone.dragging {
  border-color: var(--accent);
  background: var(--soft);
}

.drop-zone input {
  display: none;
}

.drop-title {
  font-weight: 750;
}

.upload-queue {
  display: grid;
  gap: 10px;
}

.upload-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  display: grid;
  gap: 8px;
}

progress {
  width: 100%;
  height: 10px;
  accent-color: var(--accent);
}

.library-panel {
  min-height: 540px;
  display: grid;
  gap: 14px;
}

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

.media-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
  display: grid;
}

.media-thumb {
  width: 100%;
  aspect-ratio: 3 / 2;
  background: #edf1f6;
  object-fit: cover;
  display: block;
}

.music-thumb {
  aspect-ratio: 3 / 2;
  display: grid;
  place-items: center;
  background: #f3f4f6;
  color: var(--accent-strong);
  font-weight: 800;
  font-size: 34px;
}

.media-body {
  padding: 12px;
  display: grid;
  gap: 10px;
}

.media-key {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.media-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}

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

.card-actions button {
  min-height: 34px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 0 10px;
}

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

audio {
  width: 100%;
}

.load-more {
  justify-self: center;
}

.image-dialog {
  width: min(920px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 0;
}

.image-dialog::backdrop {
  background: rgba(15, 23, 42, 0.44);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

#dialogImage {
  width: 100%;
  max-height: 58vh;
  object-fit: contain;
  background: #f8fafc;
  display: block;
}

.resize-controls {
  padding: 14px;
  border-top: 1px solid var(--line);
}

#imageUrlOutput {
  min-height: 76px;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  resize: vertical;
}

@media (max-width: 860px) {
  .manager-view {
    padding: 14px;
  }

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

  .upload-panel {
    position: static;
  }
}
