:root {
  color-scheme: light;
  --bg: #f3f0e9;
  --surface: rgba(255, 255, 255, .76);
  --surface-solid: #fff;
  --ink: #17211f;
  --muted: #66716d;
  --line: rgba(23, 33, 31, .12);
  --green: #175f4c;
  --green-soft: #dbe9e1;
  --orange: #e36e3d;
  --shadow: 0 24px 80px rgba(29, 48, 42, .12);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101513;
  --surface: rgba(27, 36, 33, .78);
  --surface-solid: #1b2421;
  --ink: #edf3ef;
  --muted: #a4b0aa;
  --line: rgba(237, 243, 239, .12);
  --green: #7fc5aa;
  --green-soft: #263d34;
  --orange: #ff8c5d;
  --shadow: 0 24px 80px rgba(0, 0, 0, .3);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  transition: color .2s, background .2s;
}
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
[hidden] { display: none !important; }
.ambient { position: fixed; z-index: -1; border-radius: 50%; filter: blur(10px); opacity: .5; pointer-events: none; }
.ambient-one { width: 420px; height: 420px; top: -180px; right: -80px; background: #b9d9c9; }
.ambient-two { width: 340px; height: 340px; bottom: -170px; left: -100px; background: #edc5a9; }
:root[data-theme="dark"] .ambient { opacity: .12; }
.eyebrow { margin: 0 0 10px; color: var(--orange); font-size: 11px; font-weight: 800; letter-spacing: .18em; }

.login-shell { width: min(440px, calc(100% - 32px)); margin: 0 auto; padding: 10vh 0 60px; text-align: center; }
.brand-mark, .brand > span {
  display: inline-grid; place-items: center; color: #fff; background: var(--green);
  border-radius: 18px; font-family: ui-serif, Georgia, serif; font-weight: 700;
}
.brand-mark { width: 70px; height: 70px; margin-bottom: 32px; font-size: 30px; box-shadow: var(--shadow); }
.login-shell h1 { margin: 0; font: 700 clamp(42px, 9vw, 64px)/1.08 ui-serif, Georgia, serif; }
.lead { color: var(--muted); line-height: 1.8; }
.login-card { display: grid; gap: 18px; margin-top: 38px; padding: 30px; text-align: left; border: 1px solid var(--line); border-radius: 28px; background: var(--surface); backdrop-filter: blur(16px); box-shadow: var(--shadow); }
label { display: grid; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 700; }
input, select {
  min-height: 46px; padding: 0 14px; color: var(--ink); background: var(--surface-solid);
  border: 1px solid var(--line); border-radius: 12px; outline: none;
}
input:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 18%, transparent); }
.primary-button {
  display: inline-flex; min-height: 48px; align-items: center; justify-content: center; gap: 18px;
  padding: 0 20px; color: #fff; background: #175f4c; border: 0; border-radius: 14px;
  font-weight: 800; cursor: pointer; transition: transform .18s, opacity .18s;
}
.primary-button:hover { transform: translateY(-2px); }
.primary-button:disabled { opacity: .55; cursor: wait; transform: none; }
.form-message { min-height: 1.2em; margin: 0; color: var(--orange); font-size: 13px; }

.app-shell { width: min(1240px, calc(100% - 48px)); margin: 0 auto; padding-bottom: 80px; }
.topbar { display: flex; min-height: 88px; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; }
.brand > span { width: 38px; height: 38px; border-radius: 11px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.icon-button, .text-button {
  min-width: 42px; height: 42px; padding: 0 13px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); cursor: pointer;
}
.text-button { color: var(--muted); }
.hero { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 40px; padding: 72px 0 46px; }
.hero h1 { margin: 0; font: 650 clamp(46px, 7vw, 82px)/1.05 ui-serif, Georgia, serif; letter-spacing: -.045em; }
.hero h1 em { color: var(--green); font-style: normal; }
.storage-card { display: grid; min-width: 220px; gap: 6px; padding: 25px; border: 1px solid var(--line); border-radius: 24px; background: var(--surface); box-shadow: var(--shadow); }
.storage-card span, .storage-card small { color: var(--muted); }
.storage-card strong { font-size: 30px; }

.upload-panel { display: grid; grid-template-columns: 1fr 1.15fr; gap: 32px; padding: 32px; border-radius: 30px; background: var(--green); color: #fff; box-shadow: var(--shadow); }
.upload-copy h2, .library h2 { margin: 0 0 9px; font: 650 30px/1.2 ui-serif, Georgia, serif; }
.upload-copy p:last-child { max-width: 410px; color: rgba(255,255,255,.7); line-height: 1.7; }
.drop-zone {
  display: grid; min-height: 180px; place-items: center; align-content: center; gap: 7px;
  border: 1px dashed rgba(255,255,255,.52); border-radius: 22px; background: rgba(255,255,255,.08);
  cursor: pointer; transition: background .18s, transform .18s;
}
.drop-zone:hover, .drop-zone.dragging { background: rgba(255,255,255,.16); transform: translateY(-2px); }
.drop-zone span { color: rgba(255,255,255,.67); font-size: 13px; }
.drop-icon { font-size: 32px; font-weight: 200; }
.upload-queue { grid-column: 1 / -1; padding: 20px; border-radius: 20px; background: rgba(0,0,0,.12); }
.queue-heading { display: flex; justify-content: space-between; margin-bottom: 12px; }
.queue-heading button { color: rgba(255,255,255,.75); background: none; border: 0; cursor: pointer; }
.queue-files { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 12px; }
.queue-file { flex: 0 0 auto; max-width: 220px; padding: 8px 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-radius: 9px; background: rgba(255,255,255,.12); font-size: 12px; }
.upload-progress { height: 5px; margin: 4px 0 16px; overflow: hidden; border-radius: 9px; background: rgba(255,255,255,.18); }
.upload-progress span { display: block; width: 0; height: 100%; background: #fff; transition: width .15s; }
.upload-panel > .form-message { grid-column: 1 / -1; color: #ffd2bf; }
.upload-panel .primary-button { color: var(--green); background: #fff; }

.library { padding-top: 70px; }
.library-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.tools { display: flex; gap: 10px; }
.search { position: relative; display: block; }
.search span { position: absolute; top: 12px; left: 13px; color: var(--muted); }
.search input { padding-left: 36px; }
.media-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.media-card { overflow: hidden; border: 1px solid var(--line); border-radius: 22px; background: var(--surface); box-shadow: 0 8px 30px rgba(25,38,34,.06); }
.media-preview { position: relative; display: grid; width: 100%; aspect-ratio: 4 / 3; place-items: center; padding: 0; overflow: hidden; border: 0; background: var(--green-soft); cursor: pointer; }
.media-preview img, .media-preview video { width: 100%; height: 100%; object-fit: cover; }
.video-placeholder { font-size: 42px; color: var(--green); }
.media-info { padding: 15px; }
.media-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.media-meta { display: flex; justify-content: space-between; margin: 7px 0 14px; color: var(--muted); font-size: 11px; }
.media-actions { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.media-actions a, .media-actions button { display: grid; min-height: 38px; place-items: center; border: 1px solid var(--line); border-radius: 10px; background: transparent; color: var(--ink); text-decoration: none; cursor: pointer; }
.media-actions button { width: 40px; color: #bd4c3f; }
.empty-state { padding: 70px 20px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 24px; }
.empty-state span { font-size: 42px; color: var(--green); }
.empty-state h3 { margin-bottom: 4px; color: var(--ink); }
.preview-dialog { max-width: min(920px, calc(100% - 32px)); max-height: 90vh; padding: 16px; color: var(--ink); background: var(--surface-solid); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); }
.preview-dialog::backdrop { background: rgba(4,10,8,.75); backdrop-filter: blur(6px); }
.preview-dialog img, .preview-dialog video { display: block; max-width: 100%; max-height: 76vh; margin: auto; border-radius: 14px; }
.preview-dialog p { margin: 12px 42px 2px 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dialog-close { position: absolute; z-index: 2; top: 12px; right: 12px; width: 38px; height: 38px; color: #fff; background: rgba(0,0,0,.62); border: 0; border-radius: 50%; font-size: 24px; cursor: pointer; }

@media (max-width: 900px) {
  .media-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .upload-panel { grid-template-columns: 1fr; }
  .upload-queue, .upload-panel > .form-message { grid-column: auto; }
}
@media (max-width: 680px) {
  .app-shell { width: min(100% - 28px, 1240px); }
  .hero { grid-template-columns: 1fr; padding-top: 48px; }
  .storage-card { min-width: 0; }
  .upload-panel { padding: 22px; border-radius: 24px; }
  .library-heading { align-items: stretch; flex-direction: column; }
  .tools { display: grid; grid-template-columns: 1fr auto auto; }
  .search input { width: 100%; }
  .media-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
}
@media (max-width: 430px) {
  .media-grid { grid-template-columns: 1fr; }
  .hero h1 { font-size: 44px; }
  .topbar { min-height: 74px; }
}
