@import url('./studio-docs.css');

/* ================= shell ================= */
.studio-body { background: var(--paper); }
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 8px;
  padding: 20px 14px 14px; border-right: 1px solid var(--line); background: var(--surface-2);
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 18px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none;
  background: var(--ink); color: #f4efe7; font-family: var(--font-display); font-size: 22px; font-style: italic;
}
.brand-name { font-family: var(--font-display); font-size: 19px; font-weight: 600; line-height: 1.1; }
.brand-sub { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); }
.brand-text { min-width: 0; }
.brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 12px; height: 38px; padding: 0 12px; border-radius: 8px;
  color: var(--ink-2); text-decoration: none; font-weight: 500; transition: background 0.15s, color 0.15s;
}
.nav-item svg { color: var(--ink-3); }
.nav-item:hover { background: var(--paper-2); color: var(--ink); }
.nav-item.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); border: 1px solid var(--line); }
.nav-item.active svg { color: var(--accent); }
.sidebar-foot { display: flex; align-items: center; gap: 8px; padding: 12px 6px 0; border-top: 1px solid var(--line); }
.sidebar-user { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; font-size: 12.5px; }
.sidebar-user-text { min-width: 0; }
.sidebar-user-text div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: color-mix(in srgb, var(--accent) 18%, #fff); color: var(--accent); font-weight: 600;
}
.main { min-width: 0; }
.mobile-bar { display: none; }

/* ================= page scaffolding ================= */
.page { padding: 36px 44px 96px; max-width: 1320px; margin: 0 auto; }
.page-narrow { max-width: 980px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 28px; flex-wrap: wrap; }
.page-titles { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.page-title { font-family: var(--font-display); font-size: 42px; font-weight: 500; letter-spacing: -0.015em; line-height: 1.05; }
.page-sub { color: var(--ink-2); display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.page-sub .meta { display: inline-flex; align-items: center; gap: 6px; }
.page-sub .meta svg { width: 15px; height: 15px; color: var(--ink-3); }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-3); text-decoration: none; font-size: 13px; margin-bottom: 4px; width: fit-content; }
.back-link:hover { color: var(--ink); }
.back-link svg { width: 15px; height: 15px; }

.section { margin-top: 32px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-title { font-family: var(--font-display); font-size: 25px; font-weight: 500; }

.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 8px; }
.row-wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .span-2 { grid-column: span 2; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }

/* ================= tabs ================= */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 24px; overflow-x: auto; scrollbar-width: none; }
.tab {
  position: relative; height: 42px; padding: 0 12px; border: 0; background: none; cursor: pointer; white-space: nowrap;
  color: var(--ink-3); font-weight: 500; display: inline-flex; align-items: center; gap: 8px;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); }
.tab.active::after { content: ''; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; background: var(--ink); border-radius: 2px; }
.tab-count { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--paper-2); color: var(--ink-2); }

/* ================= tables & lists ================= */
.table-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3);
  padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap;
}
.table td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover td { background: var(--surface-2); }
.table .right { text-align: right; }
.cell-title { font-weight: 500; color: var(--ink); }
.cell-sub { font-size: 12.5px; color: var(--ink-3); }

.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.list-row {
  display: flex; align-items: center; gap: 14px; padding: 13px 16px; border-bottom: 1px solid var(--line);
  text-decoration: none; color: inherit; min-width: 0;
}
.list-row:last-child { border-bottom: 0; }
a.list-row:hover, button.list-row:hover { background: var(--surface-2); }
button.list-row { width: 100%; border-left: 0; border-right: 0; border-top: 0; background: none; text-align: left; cursor: pointer; font: inherit; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row .sub { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-icon { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; background: var(--paper); color: var(--ink-2); flex: none; }
.list-icon svg { width: 17px; height: 17px; }
.date-chip {
  width: 44px; flex: none; text-align: center; border-radius: 9px; overflow: hidden; border: 1px solid var(--line); background: var(--surface);
}
.date-chip .m { font-size: 10px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; background: var(--ink); color: #f4efe7; padding: 2px 0; }
.date-chip .d { font-family: var(--font-display); font-size: 21px; line-height: 1.2; padding: 1px 0 3px; font-variant-numeric: lining-nums; }

.kv { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 10px 14px; font-size: 13.5px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ================= stats ================= */
.stat { padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; }
.stat-label { font-size: 12px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.stat-label svg { width: 14px; height: 14px; }
.stat-value { font-family: var(--font-display); font-size: 34px; font-weight: 500; line-height: 1.05; letter-spacing: -0.01em; font-variant-numeric: lining-nums tabular-nums; }
.stat-foot { font-size: 12px; color: var(--ink-3); }

/* ================= search / toolbar ================= */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.search { position: relative; flex: 1; max-width: 380px; min-width: 200px; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--ink-3); pointer-events: none; }
.search .input { padding-left: 34px; }
.seg { display: inline-flex; padding: 3px; border-radius: 9px; background: var(--paper-2); gap: 2px; }
.seg button { height: 30px; padding: 0 12px; border: 0; background: none; border-radius: 7px; cursor: pointer; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; }
.seg button svg { width: 15px; height: 15px; }
.seg button.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* ================= auth ================= */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-art {
  position: relative; display: flex; align-items: flex-end; padding: 56px; color: #f4efe7; overflow: hidden;
  background:
    radial-gradient(1200px 600px at 20% 110%, rgba(196, 160, 120, 0.55), transparent 60%),
    radial-gradient(900px 500px at 90% -10%, rgba(120, 96, 80, 0.6), transparent 60%),
    linear-gradient(160deg, #2a2622 0%, #171513 100%);
}
.auth-art::after {
  content: ''; position: absolute; inset: 28px; border: 1px solid rgba(244, 239, 231, 0.18); border-radius: 18px; pointer-events: none;
}
.auth-art-inner { position: relative; max-width: 520px; display: flex; flex-direction: column; gap: 16px; }
.auth-art .eyebrow { color: rgba(244, 239, 231, 0.6); }
.auth-art h1 { font-size: 56px; line-height: 1.02; }
.auth-art h1 em { font-style: italic; color: #e7cfb4; }
.auth-art p { color: rgba(244, 239, 231, 0.75); font-size: 15px; max-width: 420px; }
.auth-card { align-self: center; justify-self: center; width: min(400px, 90vw); display: flex; flex-direction: column; gap: 16px; padding: 32px 0; }
.auth-card h2 { font-size: 40px; margin-bottom: 8px; }

/* ================= projects board ================= */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(212px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 12px; align-items: start; }
.board-col { background: var(--paper-2); border-radius: 12px; padding: 10px; min-height: 160px; display: flex; flex-direction: column; gap: 8px; transition: background 0.15s; }
.board-col.drop { background: color-mix(in srgb, var(--accent) 14%, var(--paper-2)); }
.board-col-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 6px; font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); }
.board-card {
  display: block; padding: 12px 12px 10px; border-radius: 9px; background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow-sm); text-decoration: none; color: inherit; cursor: grab;
}
.board-card:hover { border-color: var(--line-2); }
.board-card.dragging { opacity: 0.5; }
.board-card .title { font-weight: 500; margin-bottom: 4px; }
.board-card .meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--ink-3); }

/* ================= galleries ================= */
.gallery-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; }
.gallery-card { display: flex; flex-direction: column; gap: 10px; text-decoration: none; color: inherit; }
.gallery-card-cover {
  position: relative; aspect-ratio: 4 / 3; border-radius: 12px; overflow: hidden; background: var(--paper-2);
  box-shadow: var(--shadow-sm); display: grid; place-items: center; color: var(--ink-3);
}
.gallery-card-cover img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.6s var(--ease); }
.gallery-card:hover .gallery-card-cover img { transform: scale(1.03); }
.gallery-card-cover .badge { position: absolute; top: 10px; left: 10px; background: rgba(255,255,255,0.92); }
.gallery-card-title { font-family: var(--font-display); font-size: 22px; line-height: 1.1; }
.gallery-card-meta { font-size: 12.5px; color: var(--ink-3); display: flex; gap: 10px; flex-wrap: wrap; margin-top: 2px; }

/* ================= gallery editor ================= */
.editor { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 24px; align-items: start; }
.scene-list { position: sticky; top: 20px; display: flex; flex-direction: column; gap: 2px; }
.scene-item {
  display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px; border-radius: 8px; border: 1px solid transparent;
  background: none; cursor: pointer; text-align: left; color: var(--ink-2); font-weight: 500; width: 100%;
}
.scene-item:hover { background: var(--paper-2); color: var(--ink); }
.scene-item.active { background: var(--surface); border-color: var(--line); color: var(--ink); box-shadow: var(--shadow-sm); }
.scene-item.drop { background: color-mix(in srgb, var(--accent) 16%, var(--surface)); border-color: var(--accent); }
.scene-item .name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scene-item .count { font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.scene-item .scene-more { opacity: 0; }
.scene-item:hover .scene-more, .scene-item.active .scene-more { opacity: 1; }
.scene-list-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 10px 6px; }

.dropzone {
  position: relative; border: 1.5px dashed var(--line-2); border-radius: 14px; background: var(--surface-2);
  padding: 28px; display: flex; align-items: center; gap: 20px; transition: border-color 0.15s, background 0.15s;
}
.dropzone.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
.dropzone-icon { width: 52px; height: 52px; border-radius: 50%; background: var(--surface); border: 1px solid var(--line); display: grid; place-items: center; color: var(--accent); flex: none; }
.dropzone-icon svg { width: 22px; height: 22px; }
.dropzone h3 { font-family: var(--font-display); font-size: 23px; }
.dropzone p { color: var(--ink-3); font-size: 13px; }
.drop-overlay {
  position: fixed; inset: 0; z-index: 800; display: grid; place-items: center; pointer-events: none;
  background: rgba(30, 28, 25, 0.35); backdrop-filter: blur(2px); animation: fade-in 0.15s;
}
.drop-overlay-card { padding: 32px 44px; border-radius: 18px; background: var(--surface); box-shadow: var(--shadow-lg); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.drop-overlay-card h3 { font-family: var(--font-display); font-size: 30px; }

.select-bar {
  position: sticky; top: 12px; z-index: 50; display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 16px;
  border-radius: 12px; background: var(--ink); color: #f4efe7; box-shadow: var(--shadow-lg); margin-bottom: 14px;
}
.select-bar .btn-ghost { color: #e9e2d7; }
.select-bar .btn-ghost:hover { background: rgba(255,255,255,0.1); color: #fff; }

.thumb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.thumb {
  position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--paper-2); cursor: pointer;
  outline: 2px solid transparent; outline-offset: 2px; transition: outline-color 0.1s; content-visibility: auto; contain-intrinsic-size: 150px;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb.selected { outline-color: var(--accent); }
.thumb.selected::after { content: ''; position: absolute; inset: 0; background: color-mix(in srgb, var(--accent) 18%, transparent); }
.thumb-check {
  position: absolute; z-index: 2; top: 7px; left: 7px; width: 22px; height: 22px; border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.9); background: rgba(0,0,0,0.15); display: grid; place-items: center; color: #fff;
  opacity: 0; transition: opacity 0.15s;
}
.thumb-check svg { width: 14px; height: 14px; }
.thumb:hover .thumb-check, .thumb.selected .thumb-check, .thumb-grid.selecting .thumb-check { opacity: 1; }
.thumb.selected .thumb-check { background: var(--accent); border-color: var(--accent); }
.thumb-placeholder { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--ink-3); padding: 8px; text-align: center; font-size: 11px; overflow-wrap: anywhere; }
.thumb-placeholder svg { width: 22px; height: 22px; }
.thumb-tag {
  position: absolute; z-index: 2; bottom: 6px; right: 6px; display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 6px; border-radius: 999px; background: rgba(20, 18, 16, 0.72); color: #fff; font-size: 11px; font-weight: 500;
}
.thumb-tag svg { width: 11px; height: 11px; }
.thumb-cover { position: absolute; z-index: 2; top: 7px; right: 7px; }
.thumb.uploading img { opacity: 0.55; }

.share-box { display: flex; gap: 8px; align-items: center; padding: 6px 6px 6px 12px; border: 1px solid var(--line-2); border-radius: 10px; background: var(--surface); min-width: 0; }
.share-box code { flex: 1; min-width: 0; font-family: var(--font-ui); font-size: 13px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.settings-group { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.settings-group + .settings-group { border-top: 1px solid var(--line); }
.settings-group h3 { font-size: 13px; font-weight: 600; letter-spacing: 0.02em; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.setting-row .text { min-width: 0; }
.setting-row .text div:first-child { font-weight: 500; }
.setting-row .text div + div { font-size: 12.5px; color: var(--ink-3); }

.theme-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.theme-option { border: 1.5px solid var(--line); border-radius: 10px; padding: 8px; background: var(--surface); cursor: pointer; display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 500; }
.theme-option.active { border-color: var(--ink); }
.theme-swatch { height: 46px; border-radius: 6px; display: grid; place-items: center; font-family: var(--font-display); font-style: italic; font-size: 18px; }

/* ================= activity ================= */
.timeline { display: flex; flex-direction: column; }
.timeline-item { display: flex; gap: 12px; padding: 10px 0; position: relative; }
.timeline-item::before { content: ''; position: absolute; left: 13px; top: 36px; bottom: -8px; width: 1px; background: var(--line); }
.timeline-item:last-child::before { display: none; }
.timeline-dot { width: 27px; height: 27px; border-radius: 50%; display: grid; place-items: center; background: var(--paper-2); color: var(--ink-2); flex: none; }
.timeline-dot svg { width: 14px; height: 14px; }
.timeline-body { min-width: 0; font-size: 13.5px; }
.timeline-body .when { font-size: 12px; color: var(--ink-3); }

/* ================= upload tray ================= */
.upload-tray {
  position: fixed; z-index: 700; right: 20px; bottom: 20px; width: 380px; max-width: calc(100vw - 32px);
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden;
  animation: rise-in 0.25s var(--ease);
}
.upload-head { display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 16px; }
.upload-head .grow { flex: 1; min-width: 0; }
.upload-title { font-weight: 600; font-size: 13.5px; }
.upload-sub { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.progress { height: 4px; background: var(--paper-2); overflow: hidden; }
.progress-bar { height: 100%; background: var(--accent); transition: width 0.4s var(--ease); }
.progress.done .progress-bar { background: var(--success); }
.upload-body { max-height: 280px; overflow-y: auto; border-top: 1px solid var(--line); }
.upload-row { display: flex; align-items: center; gap: 10px; padding: 8px 16px; font-size: 12.5px; }
.upload-row + .upload-row { border-top: 1px solid var(--line); }
.upload-row .name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upload-row .mini-bar { width: 70px; height: 3px; border-radius: 3px; background: var(--paper-2); overflow: hidden; flex: none; }
.upload-row .mini-bar div { height: 100%; background: var(--accent); }
.upload-row .state { font-size: 11.5px; color: var(--ink-3); flex: none; min-width: 42px; text-align: right; font-variant-numeric: tabular-nums; }
.upload-row.error .state { color: var(--danger); }
.upload-foot { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); background: var(--surface-2); }

/* ================= responsive ================= */
@media (max-width: 1100px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; z-index: 950; left: 0; top: 0; width: 272px; transform: translateX(-100%); transition: transform 0.25s var(--ease); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .sidebar-scrim { position: fixed; inset: 0; z-index: 940; background: rgba(0,0,0,0.3); }
  .mobile-bar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); position: sticky; top: 0; z-index: 60; }
  .mobile-title { font-size: 20px; }
  .page { padding: 24px 18px 96px; }
  .page-title { font-size: 34px; }
  .grid-2, .grid-3, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid .span-2 { grid-column: auto; }
  .editor { grid-template-columns: minmax(0, 1fr); }
  .scene-list { position: static; flex-direction: row; overflow-x: auto; gap: 6px; }
  .scene-item { width: auto; flex: none; }
  .scene-list-head { display: none; }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-art { display: none; }
  .dropzone { flex-direction: column; text-align: center; }
  .thumb-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 6px; }
}
@media (max-width: 560px) {
  .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .upload-tray { right: 16px; left: 16px; width: auto; bottom: 16px; }
}
