:root {
  /* Apple-like light system: one pale canvas, hairline chrome, SF stack. */
  --bg: #f5f5f7;
  --panel: #ffffff;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --line: #d2d2d7;
  --row-hover: #f5f5f7;
  --row-active: #e8f0fe;
  --accent: #0071e3;
  --radius: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI",
    Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  overflow: hidden;
}

#app {
  display: grid;
  grid-template-columns: minmax(280px, 28vw) 1fr;
  height: 100%;
  gap: 10px;
  padding: 10px;
}

#left {
  display: grid;
  grid-template-rows: auto 1fr 1fr;
  gap: 10px;
  min-height: 0;
}

.brand-bar {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.logo-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  flex: none;
  background: linear-gradient(160deg, #1d1d1f 0%, #6e6e73 100%);
}
.brand-title {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.brand-tagline {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.4;
}
.brand-sub {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.45;
  word-break: break-all;
}
.brand-sub a, .meta-list a {
  color: var(--accent);
  text-decoration: none;
}
.brand-sub a:hover, .meta-list a:hover { text-decoration: underline; }
.meta-list dd {
  overflow-wrap: anywhere;
  word-break: break-all;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: -0.01em;
  color: var(--muted);
}
.panel-head input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  font: inherit;
  background: var(--bg);
  color: var(--ink);
}
.panel-head input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.15);
}
.panel-foot {
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.75rem;
}

.table-wrap { flex: 1; overflow: auto; min-height: 0; }
#clip-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}
#clip-table th, #clip-table td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid #ececef;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#clip-table th {
  position: sticky;
  top: 0;
  background: #fafafa;
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.02em;
}
#clip-table th:first-child, #clip-table td:first-child { width: 42%; }
#clip-table tbody tr { cursor: pointer; }
#clip-table tbody tr:hover { background: var(--row-hover); }
#clip-table tbody tr.active { background: var(--row-active); }

.meta-list {
  margin: 0;
  padding: 10px 14px 16px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.meta-list > div { display: grid; gap: 2px; }
.meta-list dt {
  font-size: 0.7rem;
  letter-spacing: 0.02em;
  color: var(--muted);
}
.meta-list dd {
  margin: 0;
  font-size: 0.9rem;
  word-break: break-word;
  color: var(--ink);
}

#viewport-wrap {
  position: relative;
  background: #f5f5f7;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  min-width: 0;
}
#stage {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

#upperbar {
  position: absolute;
  top: 12px;
  right: 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none;
}
#upperbar > * { pointer-events: auto; }

.icon-btn, #view-cube button, .model-btn {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  color: var(--ink);
  border-radius: 980px;
  cursor: pointer;
  font: inherit;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.icon-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
}
#view-cube {
  display: grid;
  grid-template-columns: repeat(2, 58px);
  gap: 6px;
}
#view-cube button {
  padding: 7px 4px;
  font-size: 0.7rem;
  border-radius: 10px;
}
#model-selector { display: flex; flex-direction: column; gap: 6px; }
.model-btn {
  min-width: 96px;
  padding: 8px 12px;
  font-size: 0.72rem;
  font-weight: 500;
  border-radius: 980px;
}
.model-btn.active {
  border-color: transparent;
  background: var(--ink);
  color: #fff;
  box-shadow: none;
}

#timeline {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border: 1px solid rgba(210, 210, 215, 0.85);
  border-radius: 16px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.06);
}
#timeline button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 980px;
  width: 32px;
  height: 32px;
  cursor: pointer;
}
#scrub { flex: 1; accent-color: var(--accent); }
#time-label {
  min-width: 88px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 0.8rem;
}
.loop, .speed {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 0.75rem;
  white-space: nowrap;
}
.speed input { width: 72px; }

#status {
  position: absolute;
  left: 14px;
  top: 12px;
  max-width: 45%;
  padding: 6px 12px;
  border-radius: 980px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border: 1px solid rgba(210, 210, 215, 0.85);
  color: var(--muted);
  font-size: 0.75rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 960px) {
  #app {
    grid-template-columns: 1fr;
    grid-template-rows: 42vh 1fr;
  }
  #left { grid-template-rows: auto 1fr 0.8fr; }
  #view-cube { display: none; }
}
