:root {
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f4f6fa;
  --card: #ffffff;
  --accent: #2563eb;
  --accent-soft: #eff4ff;
  --green: #0f9d74;
  --red: #d64545;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 8px 24px rgba(16, 24, 40, 0.04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

[hidden] { display: none !important; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  height: 56px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 8px; font-size: 16px; }
.brand-dot {
  width: 10px; height: 10px; border-radius: 3px;
  background: linear-gradient(135deg, #2563eb, #0f9d74);
  display: inline-block;
}
.brand-sub { color: var(--muted); font-size: 13px; padding-left: 6px; border-left: 1px solid var(--line); }

.topbar-right { display: flex; align-items: center; gap: 16px; }
.user-name { color: var(--muted); font-size: 13px; }
.link { font-size: 13px; }

.tabs {
  flex: 0 0 auto;
  display: flex;
  gap: 6px;
  padding: 10px 20px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover { background: #f3f4f6; color: var(--ink); }
.tab.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

main { flex: 1 1 auto; min-height: 0; display: flex; }
.panel { flex: 1 1 auto; min-width: 0; padding: 28px 24px 40px; }
.panel.frame-panel { display: flex; flex-direction: column; padding: 0; }

.hero { max-width: 760px; margin: 8px auto 28px; text-align: center; }
.hero h1 { font-size: 26px; line-height: 1.35; margin: 0 0 10px; }
.hero p { margin: 0; color: var(--muted); }

.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  max-width: 1040px;
  margin: 0 auto;
}

.card {
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 170px;
}
.card:hover { transform: translateY(-2px); border-color: #c7d2fe; }
.card h2 { margin: 0; font-size: 18px; }
.card p { margin: 0; color: var(--muted); font-size: 13px; }
.card-meta { margin-top: auto; font-size: 12px; color: var(--accent); }

.kicker {
  display: inline-block;
  align-self: flex-start;
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 999px;
  letter-spacing: 1px;
}
.kicker.public { background: #ecfdf5; color: var(--green); }
.kicker.private { background: #fff7ed; color: #b45309; }

.footnote { max-width: 1040px; margin: 26px auto 0; color: var(--muted); font-size: 12px; text-align: center; }

.frame-bar {
  flex: 0 0 auto;
  height: 48px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.frame-title { font-weight: 600; }
.frame-bar .link { margin-left: auto; }

.ghost {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 13px;
  cursor: pointer;
}
.ghost:hover { border-color: #c7d2fe; color: var(--accent); }

iframe { flex: 1 1 auto; width: 100%; border: 0; background: #fff; }

.section-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 18px; }
.section-head h2 { margin: 0 0 4px; font-size: 20px; }
.muted { color: var(--muted); margin: 0; font-size: 13px; }

.drop-zone {
  border: 1.5px dashed #cbd5e1;
  border-radius: var(--radius);
  background: var(--card);
  padding: 26px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.drop-zone:hover, .drop-zone.is-over { border-color: var(--accent); background: var(--accent-soft); }
.drop-zone p { margin: 4px 0; }

.upload-status { margin: 14px 0 6px; }
.bar { height: 6px; background: #e8edf5; border-radius: 999px; overflow: hidden; }
#uploadBar { height: 100%; width: 0; background: var(--accent); transition: width 0.15s ease; }
#uploadText { display: inline-block; margin-top: 6px; font-size: 12px; color: var(--muted); }

.file-list { list-style: none; margin: 18px 0 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); overflow: hidden; }
.file-list:empty { display: none; }
.file-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.file-item:last-child { border-bottom: 0; }
.file-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta { flex: 0 0 auto; color: var(--muted); font-size: 12px; }
.file-actions { flex: 0 0 auto; display: flex; gap: 10px; }
.file-actions a, .file-actions button { font-size: 13px; }
.danger { border: 0; background: transparent; color: var(--red); cursor: pointer; padding: 0; }
.danger:hover { text-decoration: underline; }

.empty { margin-top: 18px; color: var(--muted); text-align: center; }

.gate { max-width: 520px; margin: 60px auto; text-align: center; }
.gate h2 { margin: 0 0 10px; }
.gate p { color: var(--muted); }
.primary {
  display: inline-block;
  margin-top: 12px;
  background: var(--accent);
  color: #fff;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 14px;
}
.primary:hover { text-decoration: none; opacity: 0.92; }

@media (max-width: 900px) {
  .cards { grid-template-columns: 1fr; }
  .panel { padding: 20px 16px 32px; }
  .panel.frame-panel { padding: 0; }
}

@media (max-width: 560px) {
  .topbar { padding: 0 14px; }
  .brand-sub { display: none; }
  .tabs { padding: 8px 12px; }
  .hero h1 { font-size: 22px; }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translate(-50%, 12px);
  background: #111827;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 99;
  max-width: 80vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { background: #b42318; }
