@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --bg-white: #ffffff;
  --bg-light: #fafafa;
  --bg-very-light: #f8f5ff;

  --purple-very-pale: #f5f3ff;
  --purple-light: #e5d9ff;
  --purple-medium: #9b7fc7;
  --purple-medium-dark: #7b5fa6;
  --purple-fill: #b8a9ff;

  --text-color: #000000;
  --text-muted: #3d3d3d;

  --border-color: #000000;
  --border-width: 1px;
  --border-radius: 0px;

  --spacing-sm: clamp(0.4rem, 1vw, 0.75rem);
  --spacing-md: clamp(0.75rem, 1.5vw, 1.5rem);
  --spacing-lg: clamp(1rem, 2.5vw, 2rem);

  font-family: 'Inter', sans-serif;
  line-height: 1.45;
  font-weight: 400;
  color: var(--text-color);
  background: var(--purple-very-pale);

  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--purple-very-pale);
}

.landing {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--spacing-lg);
}

.landing-logo {
  font-weight: 800;
  letter-spacing: -0.06em;
  text-transform: lowercase;
  font-size: clamp(3rem, 8vw, 6.5rem);
  color: #0b0b0b;
  position: relative;
  user-select: none;
}

.landing-logo::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -0.35em;
  width: 100%;
  height: 2px;
  background: var(--border-color);
  transform-origin: left;
  transform: scaleX(0);
  animation: landing-underline 900ms ease forwards;
}

.landing-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.1rem;
}

.landing-btn {
  min-width: 140px;
  text-align: center;
}

.landing-link {
  display: inline-block;
}

@keyframes landing-underline {
  to {
    transform: scaleX(1);
  }
}

a {
  color: var(--purple-medium-dark);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,
select {
  font: inherit;
}

/* Force TimePie-style sharp corners everywhere */
button,
select,
img,
.card,
.modal,
.pill,
.control select,
.status-error {
  border-radius: 0 !important;
}

.hidden {
  display: none !important;
}

.app {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-md);
  padding: var(--spacing-md) var(--spacing-lg);
  backdrop-filter: blur(10px);
  background: rgba(255, 255, 255, 0.75);
  background: color-mix(in srgb, var(--bg-white) 70%, transparent);
  border-bottom: var(--border-width) solid var(--border-color);
}

.brand-title {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.controls {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.control {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.control select {
  appearance: none;
  padding: 0.55rem 0.75rem;
  border-radius: var(--border-radius);
  border: var(--border-width) solid var(--border-color);
  background: var(--bg-white);
  color: var(--text-color);
}

.pill {
  padding: 0.55rem 0.8rem;
  border-radius: var(--border-radius);
  border: var(--border-width) solid var(--border-color);
  background: var(--bg-white);
  color: var(--text-color);
  cursor: pointer;
}

.pill:hover {
  background: var(--purple-fill);
}

.dash {
  display: grid;
  grid-template-columns: minmax(220px, 360px) 1fr;
  gap: var(--spacing-md);
  padding: var(--spacing-lg);
  max-width: 1600px;
  margin: 0 auto;
}

@media (max-width: 900px) {
  .dash {
    grid-template-columns: 1fr;
  }
}

.dash-left,
.dash-right {
  border: var(--border-width) solid var(--border-color);
  background: color-mix(in srgb, var(--bg-white) 75%, transparent);
  min-height: 60vh;
}

.dash-panel-title {
  padding: 0.75rem 0.9rem;
  border-bottom: var(--border-width) solid var(--border-color);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.dash-tree,
.dash-content {
  padding: 0.9rem;
}

.dash-panel-title-inner {
  padding: 0.6rem 0;
  border-bottom: 0;
}

.dash-divider {
  height: 1px;
  background: color-mix(in srgb, var(--border-color) 55%, transparent);
  margin: 1rem 0;
}

.keywords {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.6rem 0 0.2rem 0;
}

.kw {
  padding: 0.35rem 0.55rem;
  border: var(--border-width) solid var(--border-color);
  background: var(--bg-white);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
}

.kw:hover {
  background: var(--purple-very-pale);
}

.kw.is-active {
  background: var(--purple-fill);
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.6rem;
  padding-top: 0.6rem;
}

.media-thumb {
  border: var(--border-width) solid var(--border-color);
  background: var(--bg-white);
  padding: 0;
  cursor: pointer;
  display: block;
  text-decoration: none;
}

.media-thumb img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
  background: var(--bg-light);
}

.media-thumb:hover {
  background: var(--purple-very-pale);
}

.dash-input {
  padding: 0.55rem 0.75rem;
  border-radius: var(--border-radius);
  border: var(--border-width) solid var(--border-color);
  background: var(--bg-white);
  color: var(--text-color);
  min-width: min(40vw, 320px);
}

.dash-login {
  width: min(520px, 100%);
}

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

.dash-label {
  display: grid;
  gap: 0.4rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.dash-login-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.dash-muted {
  font-size: 0.9rem;
  color: var(--text-muted);
  word-break: break-word;
}

.tree-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0;
}

.tree-row.is-selected .tree-label {
  background: var(--purple-very-pale);
}

.tree-caret {
  width: 28px;
  height: 28px;
  border: var(--border-width) solid var(--border-color);
  background: var(--bg-white);
  cursor: pointer;
}

.tree-label {
  flex: 1;
  text-align: left;
  border: var(--border-width) solid var(--border-color);
  background: var(--bg-white);
  padding: 0.35rem 0.55rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
}

.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0 0 0.8rem 0;
  border-bottom: var(--border-width) solid var(--border-color);
  margin-bottom: 0.8rem;
}

.content-path {
  font-weight: 700;
  letter-spacing: -0.02em;
}

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

.content-section-title {
  margin-top: 0.9rem;
  margin-bottom: 0.4rem;
  font-weight: 700;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.content-list {
  display: grid;
  gap: 0.45rem;
}

.content-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  padding: 0.4rem 0;
  border-bottom: 1px dashed color-mix(in srgb, var(--border-color) 45%, transparent);
}

.content-row-left {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.6rem;
  align-items: start;
}

.content-grid {
  display: grid;
  gap: 0.65rem;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

.content-day {
  grid-column: 1 / -1;
  padding: 0.45rem 0.6rem;
  border: var(--border-width) solid var(--border-color);
  background: color-mix(in srgb, var(--bg-white) 80%, transparent);
  font-weight: 700;
  color: var(--text-muted);
}

.tile {
  border: var(--border-width) solid var(--border-color);
  background: color-mix(in srgb, var(--bg-white) 80%, transparent);
  display: grid;
  overflow: hidden;
  content-visibility: auto;
  contain-intrinsic-size: 220px 280px;
}

.tile.is-selected {
  outline: 2px solid color-mix(in srgb, var(--purple-fill) 55%, transparent);
}

.tile-main {
  display: grid;
  gap: 0.4rem;
  padding: 0.5rem;
  text-decoration: none;
  color: inherit;
}

.tile-folder {
  text-align: left;
  font-weight: 700;
  background: var(--purple-light);
  border: 0;
  cursor: pointer;
}

.tile-thumb {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border: var(--border-width) solid var(--border-color);
  background: var(--bg-white);
}

.tile-fallback {
  width: 100%;
  aspect-ratio: 1 / 1;
  border: var(--border-width) dashed var(--border-color);
  display: grid;
  place-items: center;
  color: var(--text-muted);
  font-weight: 700;
  padding: 0.5rem;
  word-break: break-word;
}

.tile-name {
  font-weight: 700;
  font-size: 0.9rem;
  word-break: break-word;
}

.tile-bar {
  display: flex;
  gap: 0.35rem;
  padding: 0.5rem;
  border-top: 1px dashed color-mix(in srgb, var(--border-color) 45%, transparent);
  flex-wrap: wrap;
  align-items: center;
}

.content-item-wrap {
  display: grid;
  gap: 0.2rem;
}

.content-item {
  display: inline-block;
  padding: 0.35rem 0.55rem;
  border: var(--border-width) solid var(--border-color);
  background: var(--bg-white);
  font-weight: 600;
  color: var(--text-color);
  text-decoration: none;
  word-break: break-word;
}

.content-item:hover {
  background: var(--purple-very-pale);
  text-decoration: none;
}

.content-row button.content-item {
  background: var(--purple-light);
}

.content-row button.content-item:hover {
  background: var(--purple-fill);
}

.content-row a.content-item {
  background: var(--purple-very-pale);
}

.content-row a.content-item:hover {
  background: var(--purple-light);
}

.content-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.content-row-actions {
  display: flex;
  gap: 0.5rem;
  align-items: start;
  flex-wrap: wrap;
}

.pill.danger {
  background: #fff2f2;
}

.pill.danger:hover {
  background: #ffd7d7;
}

.pill.small {
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
}

.toast-host {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 80;
  display: grid;
  gap: 0.5rem;
  max-width: min(560px, calc(100vw - 28px));
}

.toast {
  border: var(--border-width) solid var(--border-color);
  background: var(--bg-white);
  padding: 0.6rem 0.75rem;
  box-shadow: none;
  font-weight: 600;
}

.toast.ok {
  background: color-mix(in srgb, #eefcf0 60%, var(--bg-white));
}

.toast.err {
  background: color-mix(in srgb, #fff2f2 70%, var(--bg-white));
}

.migrations-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.migrations {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
  overflow-anchor: none;
}

.migration-row {
  display: grid;
  gap: 0.15rem;
  padding: 0.65rem 0.75rem;
  border: var(--border-width) solid var(--border-color);
  background: color-mix(in srgb, var(--bg-white) 84%, transparent);
}

.migration-topline {
  display: flex;
  gap: 0.5rem;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
}

.migration-title {
  font-weight: 600;
}

.migration-badge {
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  border: var(--border-width) solid var(--border-color);
  background: var(--bg-white);
  font-size: 0.85rem;
}

.migration-badge.running {
  background: var(--purple-very-pale);
}

.migration-badge.done {
  background: #eefcf0;
}

.migration-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  word-break: break-word;
}

.qwen-progress {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.8rem;
  padding-top: 0.8rem;
  border-top: 1px dashed color-mix(in srgb, var(--border-color) 45%, transparent);
}

.qwen-progress-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.qwen-bar {
  height: 12px;
  border: var(--border-width) solid var(--border-color);
  background: var(--bg-white);
}

.qwen-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--purple-fill);
}

.upload-progress {
  display: grid;
  gap: 0.5rem;
  padding: 0.75rem;
  border: var(--border-width) solid var(--border-color);
  background: color-mix(in srgb, var(--bg-white) 80%, transparent);
  margin-bottom: 0.8rem;
}

.op-progress {
  display: grid;
  gap: 0.5rem;
  padding: 0.75rem;
  border: var(--border-width) solid var(--border-color);
  background: color-mix(in srgb, var(--bg-white) 80%, transparent);
  margin-bottom: 0.8rem;
}

.jobs {
  display: grid;
  gap: 0.6rem;
  padding: 0.75rem;
  border: var(--border-width) solid var(--border-color);
  background: color-mix(in srgb, var(--bg-white) 82%, transparent);
  margin-bottom: 0.8rem;
}

.job-row {
  display: grid;
  gap: 0.35rem;
  padding: 0.65rem 0.75rem;
  border: var(--border-width) solid var(--border-color);
  background: color-mix(in srgb, var(--bg-white) 88%, transparent);
}

.job-top {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: baseline;
  flex-wrap: wrap;
}

.job-title {
  font-weight: 700;
}

.job-detail {
  font-size: 0.85rem;
  color: var(--text-muted);
  word-break: break-word;
}

.job-bar {
  height: 10px;
  border: var(--border-width) solid var(--border-color);
  background: var(--bg-white);
  overflow: hidden;
}

.job-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--purple-fill);
  transition: width 120ms ease;
}

.job-bar-fill.indeterminate {
  width: 35%;
  animation: indet 1100ms ease-in-out infinite;
}

@keyframes indet {
  0% {
    transform: translateX(-50%);
  }
  50% {
    transform: translateX(90%);
  }
  100% {
    transform: translateX(250%);
  }
}

.op-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
}

.op-left {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  min-width: 0;
}

.op-spinner {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 2px solid color-mix(in srgb, var(--border-color) 70%, transparent);
  border-top-color: var(--purple-fill);
  animation: spin 900ms linear infinite;
  flex: 0 0 auto;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.op-bar {
  height: 12px;
  border: var(--border-width) solid var(--border-color);
  background: var(--bg-white);
}

.op-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--purple-fill);
  transition: width 120ms ease;
}

#content.is-busy {
  pointer-events: none;
  opacity: 0.75;
  filter: saturate(0.95);
}

.dash-picker {
  width: min(980px, 100%);
  max-height: min(86vh, 900px);
}

.dash-picker-body {
  display: grid;
  grid-template-columns: minmax(240px, 360px) 1fr;
  gap: 1rem;
  padding: 1rem;
  overflow: hidden;
}

@media (max-width: 900px) {
  .dash-picker-body {
    grid-template-columns: 1fr;
  }
}

.dest-tree {
  max-height: 52vh;
  overflow: auto;
  border: var(--border-width) solid var(--border-color);
  background: color-mix(in srgb, var(--bg-white) 75%, transparent);
  padding: 0.6rem;
}

.dest-selected {
  font-weight: 700;
  padding: 0.45rem 0.6rem;
  border: var(--border-width) solid var(--border-color);
  background: var(--purple-very-pale);
  word-break: break-word;
}

.upload-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
}

.upload-bar {
  height: 12px;
  border: var(--border-width) solid var(--border-color);
  background: var(--bg-white);
}

.upload-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--purple-fill);
}

.linkpill {
  display: inline-block;
}

.content {
  padding: var(--spacing-lg);
  background: var(--purple-very-pale);
}

.content-tight {
  padding-top: var(--spacing-md);
}

.feed {
  max-width: 1400px;
  margin: 0 auto;
  display: grid;
  gap: var(--spacing-md);
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  grid-auto-rows: 8px;
  align-items: start;
}

.feed-item {
  margin: 0;
  content-visibility: auto;
  contain-intrinsic-size: 360px 520px;
  grid-row-end: span var(--masonry-span, 1);
}

.feed-day {
  grid-column: 1 / -1;
  padding: 0.45rem 0.6rem;
  border: var(--border-width) solid var(--border-color);
  background: color-mix(in srgb, var(--bg-white) 80%, transparent);
  font-weight: 700;
  color: var(--text-muted);
  grid-row-end: span var(--masonry-span, 1);
}

.card {
  width: 100%;
  display: block;
  text-align: left;
  border: var(--border-width) solid var(--border-color);
  background: var(--bg-white);
  border-radius: var(--border-radius);
  overflow: hidden;
  box-shadow: none;
  transition: transform 120ms ease, background-color 120ms ease;
  cursor: pointer;
  padding: 0;
}

.card:hover {
  transform: translateY(-1px);
  background: var(--purple-very-pale);
}

.card-img {
  display: block;
  width: 100%;
  height: auto;
  background: var(--bg-light);
}

.card-video {
  object-fit: cover;
  height: auto;
}

.card-meta {
  padding: 0.6rem 0.75rem 0.75rem 0.75rem;
}

.card-key {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status {
  max-width: 1400px;
  margin: 0.75rem auto 0 auto;
}

.status-muted {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.status-error {
  color: #7a1a1a;
  background: #fff2f2;
  border: var(--border-width) solid var(--border-color);
  padding: 0.65rem 0.8rem;
  border-radius: var(--border-radius);
  font-size: 0.9rem;
  word-break: break-word;
}

.sentinel {
  height: 1px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: var(--spacing-lg);
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 5, 20, 0.55);
  backdrop-filter: blur(6px);
  border: 0;
  cursor: pointer;
}

.modal {
  position: relative;
  width: min(1100px, 100%);
  max-height: min(85vh, 900px);
  background: var(--bg-white);
  border-radius: var(--border-radius);
  overflow: hidden;
  border: var(--border-width) solid var(--border-color);
  box-shadow: none;
  display: flex;
  flex-direction: column;
}

.modal-full {
  width: min(1400px, 100%);
  height: min(92vh, 980px);
  max-height: 92vh;
  padding: 0;
}

.modal-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-light);
  position: relative;
  padding: 44px 44px;
  overflow: hidden;
}

.modal-media {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
  display: block;
  background: var(--bg-light);
}

@media (max-width: 700px) {
  .modal-stage {
    padding: 40px 40px;
  }
  .strip-btn {
    width: 80px;
    height: 60px;
  }
}

.modal-strip {
  display: flex;
  gap: 8px;
  padding: 10px 10px;
  border-top: var(--border-width) solid var(--border-color);
  background: color-mix(in srgb, var(--bg-white) 85%, transparent);
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
}

.strip-btn {
  flex: 0 0 auto;
  width: 96px;
  height: 72px;
  padding: 0;
  border: var(--border-width) solid var(--border-color);
  background: var(--bg-light);
  cursor: pointer;
  scroll-snap-align: center;
  position: relative;
}

.strip-btn.is-active {
  outline: 2px solid var(--purple-medium-dark);
  outline-offset: 0;
}

.strip-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: var(--bg-light);
}

.strip-fallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  font-size: 18px;
  color: var(--text-muted);
  background: color-mix(in srgb, var(--purple-very-pale) 70%, var(--bg-light));
}

.modal-caption {
  padding: 0.55rem 0.75rem;
  border-top: 0;
  color: var(--text-muted);
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.modal-x {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 5;
  width: 40px;
  height: 40px;
  border: var(--border-width) solid var(--border-color);
  background: var(--bg-white);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.modal-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  width: 44px;
  height: 44px;
  border: var(--border-width) solid var(--border-color);
  background: var(--bg-white);
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
}

.modal-prev {
  left: 10px;
}

.modal-next {
  right: 10px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-sm);
  padding: 0.8rem 1rem;
  border-bottom: var(--border-width) solid var(--border-color);
}

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

.modal-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--bg-light);
}

