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

:root {
  color-scheme: light;
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #fafaf9;
  --ink: #171717;
  --ink-2: #4d4d4d;
  --ink-3: #8a8a8a;
  --border: #e8e8e5;
  --border-strong: #d9d9d4;
  --accent: #111111;
  --accent-2: #2563eb;
  --success: #0f7b4f;
  --shadow: 0 1px 2px rgba(20, 20, 20, 0.04), 0 16px 44px -34px rgba(20, 20, 20, 0.42);
  --radius: 14px;
  --sans: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body, #app { min-height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 32px;
  padding: 2px 8px;
  background: var(--bg);
  border-bottom: 0;
  backdrop-filter: none;
}

.chrome-left, .toolbar, .title-area { display: flex; align-items: center; min-width: 0; }
.chrome-left { gap: 8px; flex: 1; }
.toolbar { gap: 6px; flex: none; }
.title-area { gap: 8px; justify-content: flex-start; flex: 1; }
.brand-link, .icon-btn, .text-btn, .select-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 26px;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.brand-link { width: 26px; height: 26px; padding: 0; border-radius: 7px; }
.icon-btn { width: 26px; padding: 0; border-color: transparent; background: transparent; box-shadow: none; }
.text-btn.subtle { border-color: transparent; background: transparent; color: var(--ink-2); box-shadow: none; }
.share-btn { height: 26px; border-radius: 7px; padding: 0 9px; font-size: 12px; color: var(--ink-3); }
.avatar { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 999px; background: #3f7d73; color: #fff; font-weight: 700; font-size: 11px; letter-spacing: -.02em; }
.brand-link:hover, .icon-btn:hover, .text-btn:hover, .select-btn:hover { border-color: var(--border-strong); background: var(--surface-2); text-decoration: none; }
.icon-btn:hover { background: rgba(0,0,0,.045); border-color: transparent; }
.primary-btn { background: var(--accent); border-color: var(--accent); color: white; }
.primary-btn:hover { background: #333; color: white; }

.artifact-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; font-size: 14px; letter-spacing: -0.03em; }
.byline { flex: none; color: var(--ink-3); font-size: 12px; font-weight: 450; white-space: nowrap; opacity: .78; }
.version-trigger { display: inline-flex; align-items: center; gap: 7px; min-width: 0; border: 0; background: transparent; color: inherit; padding: 0; }
.version-trigger svg { flex: none; color: var(--ink); }
.version-pill { flex: none; font: 600 11px/1 var(--mono); color: var(--ink-3); background: transparent; border: 0; padding: 0; opacity: .78; }
.version-control { position: relative; min-width: 0; }
.version-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 50;
  width: min(360px, calc(100vw - 24px));
  display: none;
  padding: 6px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 18px 46px rgba(0,0,0,.14), 0 2px 8px rgba(0,0,0,.08);
}
.version-menu.open { display: grid; gap: 4px; }
.version-option {
  display: grid;
  gap: 4px;
  padding: 10px;
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
}
.version-option:hover { background: var(--surface-2); text-decoration: none; }
.version-option.active {
  position: relative;
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--border-strong);
  text-decoration: none;
}
.version-option.active::after {
  content: '✓';
  position: absolute;
  top: 10px;
  right: 10px;
  color: var(--ink-3);
  font: 700 12px/1 var(--sans);
}
.version-option strong { font-size: 13px; line-height: 1.15; }
.version-option span { color: var(--ink-2); font-size: 12px; line-height: 1.35; }
.version-option small { color: var(--ink-3); font: 500 11px/1 var(--mono); }

.home {
  width: min(1120px, calc(100% - 36px));
  margin: 0 auto;
  padding: 52px 0 76px;
}
.hero { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 28px; }
.kicker { margin: 0 0 8px; font: 600 12px/1 var(--mono); color: var(--ink-3); letter-spacing: .08em; text-transform: uppercase; }
h1 { margin: 0; font-size: clamp(36px, 7vw, 76px); line-height: .94; letter-spacing: -.055em; }
.lede { margin: 16px 0 0; max-width: 58ch; color: var(--ink-2); font-size: 16px; line-height: 1.55; }
.count-badge { flex: none; border: 1px solid var(--border); background: var(--surface); border-radius: 12px; padding: 10px 12px; font: 600 13px/1 var(--mono); color: var(--ink-2); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
.card {
  position: relative;
  display: grid;
  grid-template-rows: 170px auto auto auto;
  min-height: 430px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-decoration: none;
  overflow: hidden;
}
.card:hover { border-color: var(--border-strong); text-decoration: none; transform: translateY(-1px); transition: transform .15s ease, border-color .15s ease; }
.card-preview {
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
  background: #f1f1ef;
}
.card-preview iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 1440px;
  height: 900px;
  border: 0;
  transform: scale(.24);
  transform-origin: top left;
  pointer-events: none;
  background: white;
}
.card-body { padding: 18px 20px 0; }
.card h2 { margin: 0 0 8px; font-size: 19px; line-height: 1.2; letter-spacing: -0.025em; }
.card p { margin: 0; color: var(--ink-2); font-size: 14px; line-height: 1.48; }
.card-time { display: grid; gap: 4px; padding: 14px 20px 0; color: var(--ink-3); font: 500 11px/1.35 var(--mono); }
.card-meta { align-self: end; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px 20px; color: var(--ink-3); font: 500 12px/1.4 var(--mono); }
.card-actions { display: flex; gap: 6px; }
.card-copy { position: relative; z-index: 2; width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--ink-2); }
.card-copy:hover { color: var(--ink); border-color: var(--border-strong); }

.viewer {
  min-height: calc(100vh - 32px);
  display: grid;
  grid-template-columns: 1fr;
}
.frame-wrap { padding: 0 3px 0; min-height: calc(100vh - 32px); }
.frame {
  display: block;
  width: 100%;
  height: calc(100vh - 32px);
  border: 1px solid #d8d8d3;
  border-radius: 10px 10px 0 0;
  background: white;
  box-shadow: none;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0,0,0,.16);
  display: none;
}
.drawer-backdrop.open { display: block; }
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 41;
  width: min(420px, 100vw);
  height: 100vh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -20px 0 60px rgba(0,0,0,.12);
  transform: translateX(100%);
  transition: transform .18s ease;
  display: grid;
  grid-template-rows: auto 1fr;
}
.drawer.open { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px; border-bottom: 1px solid var(--border); }
.drawer-head h2 { margin: 0; font-size: 16px; }
.version-list { padding: 12px; overflow: auto; }
.version-row {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface);
  padding: 13px;
  margin-bottom: 9px;
  color: var(--ink);
  text-decoration: none;
}
.version-row:hover, .version-row.active { border-color: var(--ink); text-decoration: none; }
.version-row strong { display: block; font-size: 14px; margin-bottom: 5px; }
.version-row span { display: block; color: var(--ink-2); font-size: 13px; line-height: 1.4; }
.version-row small { display: block; color: var(--ink-3); font: 500 11px/1 var(--mono); margin-top: 8px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 60;
  transform: translateX(-50%) translateY(16px);
  opacity: 0;
  pointer-events: none;
  background: var(--ink);
  color: white;
  padding: 10px 13px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  transition: opacity .16s ease, transform .16s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.empty, .error {
  width: min(620px, calc(100% - 36px));
  margin: 80px auto;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.empty h1, .error h1 { font-size: 28px; line-height: 1.1; }
.empty p, .error p { color: var(--ink-2); }

@media (max-width: 760px) {
  .topbar { min-height: 32px; padding: 2px 6px; gap: 5px; }
  .chrome-left { gap: 8px; }
  .brand-link { width: 26px; height: 26px; }
  .artifact-title { font-size: 13px; }
  .byline, .version-pill { display: none; }
  .text-label { display: none; }
  .share-btn { width: 34px; height: 34px; padding: 0; font-size: 0; }
  .share-btn::before { content: '↗'; font-size: 16px; color: var(--ink); }
  .avatar { display: none; }
  .home { padding-top: 34px; }
  .hero { display: block; }
  .count-badge { display: inline-flex; margin-top: 18px; }
  .toolbar { gap: 4px; }
  .frame-wrap { padding: 0 3px 0; }
  .frame { height: calc(100vh - 32px); border-radius: 9px 9px 0 0; }
  .grid { grid-template-columns: 1fr; }
  .card { grid-template-rows: 140px auto auto auto; min-height: 390px; }
  .card-preview iframe { transform: scale(.2); }
  .version-menu { left: -42px; }
}
