:root {
  --bg-paper: #f2ede1;
  --bg-sage: #e7f0e6;
  --card: #fffcf5;
  --line: #d0ddd0;
  --ink: #1f2d2e;
  --muted: #5f6f70;
  --primary: #1f7a67;
  --primary-deep: #125647;
  --accent: #ab6a2d;
  --accent-soft: #f2ddc6;
  --danger-soft: #f8ded9;
  --shadow-lg: 0 24px 45px rgba(25, 42, 43, 0.16);
  --shadow-sm: 0 10px 20px rgba(26, 34, 34, 0.12);
  --radius-xl: 24px;
  --radius-l: 16px;
  --radius-m: 12px;
}

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

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(140deg, var(--bg-paper) 0%, var(--bg-sage) 100%);
  color: var(--ink);
  font-family: "Manrope", sans-serif;
}

.background-planes {
  display: none;
}

.background-planes::before,
.background-planes::after {
  content: "";
  position: absolute;
  border-radius: 50%;
}

.background-planes::before {
  width: 460px;
  height: 460px;
  left: -170px;
  top: -130px;
  background: radial-gradient(circle at center, rgba(171, 106, 45, 0.3), transparent 70%);
}

.background-planes::after {
  width: 600px;
  height: 600px;
  right: -260px;
  bottom: -280px;
  background: radial-gradient(circle at center, rgba(31, 122, 103, 0.26), transparent 72%);
}

.hidden {
  display: none !important;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.76rem;
  color: var(--accent);
}

h1,
h2 {
  margin: 0;
  font-family: "Fraunces", serif;
  line-height: 1.04;
}

button {
  border: none;
  border-radius: 999px;
  padding: 0.63rem 1rem;
  font: inherit;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  transition: transform 130ms ease, background-color 130ms ease;
}

button:hover {
  transform: translateY(-1px);
  background: var(--primary-deep);
}

button.secondary {
  background: var(--accent-soft);
  color: #5c381b;
}

button.secondary:hover {
  background: #eecfae;
}

button.danger {
  background: #b24f3f;
}

button.danger:hover {
  background: #8e3a2d;
}

input,
textarea {
  width: 100%;
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fffcf7;
  padding: 0.62rem 0.68rem;
}

textarea {
  resize: vertical;
}

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

.login-card {
  width: min(560px, 100%);
  padding: 2rem;
  border-radius: var(--radius-xl);
  border: 1px solid rgba(208, 221, 208, 0.9);
  background: linear-gradient(150deg, rgba(255, 252, 245, 0.96), rgba(255, 250, 239, 0.9));
  box-shadow: var(--shadow-lg);
}

.login-card h1 {
  margin-top: 0.4rem;
  font-size: clamp(2rem, 5vw, 2.8rem);
}

.intro {
  margin: 0.9rem 0 1rem;
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 0.8rem;
}

.login-form label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.88rem;
}

.login-error {
  margin: 0.8rem 0 0;
  color: #8d2c1d;
  min-height: 1.2rem;
}

.app-view {
  width: min(1320px, calc(100% - 1.4rem));
  margin: 1rem auto 1.5rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 1rem 1.1rem;
  border-radius: var(--radius-xl);
  background: linear-gradient(135deg, rgba(255, 252, 245, 0.96), rgba(255, 250, 239, 0.86));
  border: 1px solid rgba(208, 221, 208, 0.9);
  box-shadow: var(--shadow-lg);
}

.brand h2 {
  font-size: clamp(1.3rem, 3vw, 2rem);
  margin-top: 0.3rem;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  justify-content: flex-end;
}

.user-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid #c5d4cc;
  background: #eef7f1;
  color: #1b5d50;
  padding: 0.45rem 0.8rem;
  font-size: 0.84rem;
}

.workspace {
  margin-top: 0.9rem;
  display: grid;
  gap: 0.9rem;
}

.controls {
  background: rgba(255, 253, 248, 0.9);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-sm);
  padding: 0.9rem;
  display: grid;
  gap: 0.75rem;
}

.tabs,
.subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  flex: 1 1 auto;
}

.tab-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.add-tab-btn {
  width: 2.1rem;
  min-width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  border-radius: 999px;
  font-size: 1.2rem;
  line-height: 1;
}

.tabs button,
.subtabs button {
  background: #edf2eb;
  color: #334649;
  border: 1px solid #c7d4c7;
}

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

.filters {
  display: grid;
  gap: 0.4rem;
}

.filters label {
  display: grid;
  gap: 0.25rem;
  font-size: 0.86rem;
}

.upload-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
}

.upload-input-hidden {
  display: none;
}

.upload-status {
  min-height: 1.2rem;
  font-size: 0.78rem;
  color: #2f6559;
}

.summary-text {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.media-grid {
  display: grid;
  gap: 0.9rem;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.media-card {
  border-radius: var(--radius-l);
  border: 1px solid var(--line);
  overflow: hidden;
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.media-card.dragging {
  box-shadow: 0 24px 38px rgba(19, 35, 35, 0.34);
  transform: rotate(1.2deg);
}

.preview-open {
  all: unset;
  display: block;
  width: 100%;
  cursor: zoom-in;
}

.preview {
  aspect-ratio: 4 / 3;
  background: #ecebe7;
  overflow: hidden;
}

.preview img,
.preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 160ms ease;
}

.card-body {
  padding: 0.8rem;
  display: grid;
  gap: 0.55rem;
}

.card-body label {
  display: grid;
  gap: 0.26rem;
  font-size: 0.82rem;
}

.meta-line {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.drag-placeholder {
  border: 2px dashed #95b7ab;
  background: rgba(195, 224, 214, 0.3);
  min-height: 140px;
}

.tabs button.drag-drop-target,
.subtabs button.drag-drop-target {
  outline: 2px solid #1f7a67;
  outline-offset: 1px;
}

.card-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.saved-meta {
  font-size: 0.74rem;
  color: #2e6458;
}

.preview-dialog {
  width: min(1100px, calc(100% - 1rem));
  border: none;
  background: transparent;
  padding: 0;
}

.preview-dialog::backdrop {
  background: rgba(20, 24, 24, 0.78);
  backdrop-filter: blur(2px);
}

.preview-shell {
  position: relative;
  margin: 0;
  border-radius: var(--radius-xl);
  border: 1px solid #c9d8ce;
  background: #fffdf8;
  box-shadow: 0 35px 60px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}

.preview-close {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  z-index: 8;
  border-radius: 999px;
  width: auto;
  padding: 0.5rem 0.85rem;
}

.preview-stage {
  min-height: 60vh;
  max-height: 78vh;
  background: #121717;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.preview-stage img,
.preview-stage video {
  width: 100%;
  max-height: 78vh;
  object-fit: contain;
}

.preview-caption {
  margin: 0;
  padding: 0.6rem 0.8rem 0.8rem;
  color: var(--muted);
  font-size: 0.84rem;
}

.error {
  border-color: #d89083;
  background: var(--danger-soft);
  color: #7e2a1b;
  padding: 0.7rem;
  border-radius: var(--radius-m);
}

.empty-state {
  border: 1px dashed #bfd0c1;
  border-radius: var(--radius-l);
  padding: 2rem 1rem;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.55);
}

@media (max-width: 920px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .login-card {
    padding: 1.3rem;
  }

  .app-view {
    width: calc(100% - 0.8rem);
  }
}
