:root {
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #0d0f11;
  background: #f4f5f6;
  font-synthesis: none;
  --ink: #0d0f11;
  --steel: #30363c;
  --muted: #6b737b;
  --line: #dfe3e6;
  --panel: #ffffff;
  --soft: #eef0f2;
  --amber: #ffb400;
  --danger: #b42318;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: #f4f5f6; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }

.shell { width: min(1320px, calc(100% - 48px)); margin: 0 auto; }
.topbar { min-height: 94px; display: flex; align-items: center; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 14px; min-width: 0; }
.brand-logo { display: block; width: 188px; height: 48px; object-fit: contain; object-position: left center; }
.brand-context { padding-left: 14px; border-left: 1px solid #cfd4d8; color: var(--steel); font-size: 10px; font-weight: 850; letter-spacing: .18em; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.button { min-height: 42px; padding: 0 17px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; border: 1px solid transparent; font-weight: 750; font-size: 13px; transition: transform .16s ease, background .16s ease, border-color .16s ease; }
.button:hover { transform: translateY(-1px); }
.button:focus-visible, .card-action:focus-visible, .video-card-title:focus-visible, .video-card-thumb:focus-visible { outline: 3px solid rgba(255,180,0,.36); outline-offset: 2px; }
.button:disabled { opacity: .48; cursor: not-allowed; transform: none; }
.button-primary { background: var(--ink); color: white; }
.button-primary:hover { background: #1c2126; }
.button-secondary { background: white; color: var(--ink); border-color: var(--line); }
.button-secondary:hover { border-color: #b9c0c6; }
.text-button, .icon-button { border: 0; background: transparent; color: var(--muted); }
.text-button:hover, .icon-button:hover { color: var(--ink); }

.hero { padding: 72px 0 44px; display: flex; justify-content: space-between; align-items: end; gap: 36px; }
.eyebrow { margin: 0 0 13px; color: var(--steel); font-size: 11px; font-weight: 850; letter-spacing: .18em; }
h1 { margin: 0; max-width: 820px; font-size: clamp(40px, 6vw, 68px); line-height: .98; letter-spacing: -.05em; }
.hero-copy { margin: 20px 0 0; max-width: 680px; color: var(--muted); line-height: 1.7; font-size: 14px; }
.metric { text-align: right; min-width: 100px; }
.metric span { display: block; font-size: 42px; line-height: 1; font-weight: 800; letter-spacing: -.045em; }
.metric small { display: block; margin-top: 8px; color: var(--muted); font-size: 10px; font-weight: 850; letter-spacing: .18em; }

.toolbar { display: flex; gap: 20px; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.search { width: min(480px, 100%); height: 48px; display: flex; align-items: center; gap: 10px; padding: 0 15px; border: 1px solid var(--line); border-radius: 10px; background: white; transition: border-color .16s ease, box-shadow .16s ease; }
.search:focus-within { border-color: #b1b8be; box-shadow: 0 0 0 3px rgba(255,180,0,.12); }
.search-icon { color: #929aa1; font-size: 20px; }
.search input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); }
.search input::placeholder { color: #9aa1a7; }
.storage-summary { color: var(--muted); font-size: 12px; white-space: nowrap; }

.upload-panel { margin-bottom: 24px; padding: 18px 20px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 28px rgba(13,15,17,.04); }
.upload-panel-head { display: flex; justify-content: space-between; gap: 16px; align-items: center; }
.upload-panel-head strong, .upload-panel-head span { display: block; }
.upload-panel-head strong { font-size: 13px; }
.upload-panel-head span { margin-top: 5px; color: var(--muted); font-size: 11px; }
.progress-track { height: 6px; margin-top: 14px; overflow: hidden; border-radius: 999px; background: #e8ebed; }
.progress-bar { width: 0; height: 100%; border-radius: inherit; background: var(--amber); transition: width .16s ease; }

.drop-zone { position: relative; min-height: 360px; }
.state-card { min-height: 360px; display: grid; place-items: center; align-content: center; gap: 10px; padding: 48px 20px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); text-align: center; }
.state-card p, .grid-empty p { max-width: 420px; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.state-icon { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: var(--amber); font-size: 15px; padding-left: 2px; }
.state-error strong { color: var(--danger); }
.spinner { width: 24px; height: 24px; border: 2px solid #dfe3e6; border-top-color: var(--amber); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 30px 22px; width: 100%; }
.video-card { min-width: 0; }
.video-card-thumb { position: relative; width: 100%; aspect-ratio: 16 / 9; display: block; overflow: hidden; padding: 0; border: 1px solid #d8dde0; border-radius: 14px; background: #15191d; box-shadow: 0 2px 8px rgba(13,15,17,.04); }
.video-card-thumb::after { content: ""; position: absolute; inset: 0; z-index: 2; background: linear-gradient(180deg, transparent 55%, rgba(0,0,0,.30)); pointer-events: none; }
.video-card-image { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; object-fit: cover; transition: transform .24s ease, opacity .18s ease; }
.video-card:hover .video-card-image { transform: scale(1.025); }
.thumbnail-fallback { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 9px; color: #c7ced4; background: radial-gradient(circle at 50% 45%, #30363c 0, #1d2227 52%, #111417 100%); font-size: 10px; font-weight: 850; letter-spacing: .17em; }
.thumbnail-fallback img { width: 52px; height: 52px; }
.video-card-thumb.has-image .thumbnail-fallback { opacity: 0; }
.play-badge { position: absolute; z-index: 4; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 46px; height: 46px; display: grid; place-items: center; padding-left: 3px; border-radius: 50%; color: #fff; background: rgba(13,15,17,.75); box-shadow: 0 6px 20px rgba(0,0,0,.18); opacity: .9; transition: transform .18s ease, background .18s ease; }
.video-card:hover .play-badge { transform: translate(-50%, -50%) scale(1.07); background: rgba(13,15,17,.88); }
.duration-badge { position: absolute; z-index: 4; right: 9px; bottom: 9px; padding: 4px 6px; border-radius: 5px; color: white; background: rgba(13,15,17,.84); font-size: 10px; font-weight: 800; letter-spacing: .03em; }
.video-card-body { padding: 12px 2px 0; }
.video-card-title { display: block; width: 100%; min-height: 39px; padding: 0; overflow: hidden; border: 0; background: transparent; color: var(--ink); text-align: left; font-size: 14px; font-weight: 780; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.video-card-title:hover { color: #444b52; }
.video-card-meta { margin-top: 7px; color: var(--muted); font-size: 11px; }
.video-card-actions { margin-top: 10px; display: flex; align-items: center; gap: 8px; min-height: 30px; }
.card-action { min-height: 30px; padding: 0 9px; display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 7px; background: rgba(255,255,255,.72); color: var(--steel); font-size: 11px; font-weight: 700; }
.card-action:hover { background: #fff; border-color: #c4cbd0; }
.card-action-danger { color: var(--danger); }
.grid-empty { grid-column: 1 / -1; min-height: 260px; display: grid; place-items: center; align-content: center; gap: 8px; padding: 40px; border: 1px solid var(--line); border-radius: 14px; background: white; text-align: center; }

.drop-overlay { position: fixed; inset: 16px; z-index: 30; display: grid; place-items: center; align-content: center; gap: 8px; border: 2px dashed var(--amber); border-radius: 16px; background: rgba(244,245,246,.96); box-shadow: 0 20px 80px rgba(13,15,17,.16); }
.drop-overlay strong { font-size: 20px; }
.drop-overlay span { color: var(--muted); font-size: 12px; }

footer { min-height: 104px; margin-top: 42px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-top: 1px solid var(--line); color: #858d94; font-size: 9px; font-weight: 800; letter-spacing: .13em; }

.player-dialog { width: min(1040px, calc(100% - 28px)); padding: 0; border: 0; border-radius: 16px; background: transparent; box-shadow: 0 26px 90px rgba(0,0,0,.26); }
.player-dialog::backdrop { background: rgba(13,15,17,.66); backdrop-filter: blur(6px); }
.player-shell { overflow: hidden; border-radius: 16px; background: white; }
.player-head { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 14px 18px 14px 22px; }
.player-head small, .player-head strong { display: block; }
.player-head small { margin-bottom: 5px; color: var(--muted); font-size: 9px; letter-spacing: .15em; font-weight: 850; }
.player-head strong { max-width: 760px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.icon-button { width: 38px; height: 38px; font-size: 27px; line-height: 1; }
#videoPlayer { display: block; width: 100%; max-height: 70vh; min-height: 320px; background: #07090c; }
.player-actions { min-height: 76px; padding: 14px 18px 14px 22px; display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.player-actions span { color: var(--muted); font-size: 11px; }

.toast { position: fixed; left: 50%; bottom: 28px; z-index: 40; transform: translateX(-50%); min-width: 220px; max-width: min(520px, calc(100% - 36px)); padding: 12px 16px; border-radius: 9px; background: var(--ink); color: white; text-align: center; font-size: 12px; box-shadow: 0 10px 35px rgba(13,15,17,.2); }

[hidden] { display: none !important; }

@media (min-width: 1220px) {
  .video-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .shell { width: min(100% - 32px, 1320px); }
  .brand-context { display: none; }
  .hero { padding-top: 54px; }
  .video-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .shell { width: min(100% - 24px, 1320px); }
  .topbar { min-height: 78px; }
  .brand-logo { width: 142px; height: 36px; }
  .topbar-actions { gap: 6px; }
  .topbar-actions .button { min-height: 38px; padding: 0 11px; }
  .topbar-actions #refreshButton { display: none; }
  .hero { padding: 42px 0 30px; align-items: start; }
  .metric { display: none; }
  .toolbar { align-items: stretch; flex-direction: column; gap: 10px; }
  .search { width: 100%; }
  .storage-summary { padding-left: 2px; }
  .video-grid { grid-template-columns: 1fr; gap: 26px; }
  .video-card-title { min-height: 0; }
  footer { align-items: flex-start; flex-direction: column; justify-content: center; gap: 8px; }
  #videoPlayer { min-height: 210px; }
  .player-actions { align-items: stretch; flex-direction: column; }
  .player-actions .button { width: 100%; }
}
