:root {
  --bg: #020617;
  --panel: rgba(15, 23, 42, 0.82);
  --panel-solid: #0f172a;
  --card: #111827;
  --line: rgba(148, 163, 184, 0.22);
  --line-strong: rgba(148, 163, 184, 0.34);
  --text: #e5e7eb;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-2: #22c55e;
  --danger: #fb7185;
  --warning: #fbbf24;
  --shadow: 0 22px 80px rgba(0, 0, 0, 0.34);
  --radius: 24px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif;
  background:
    radial-gradient(circle at 8% 0%, rgba(56, 189, 248, .22), transparent 28%),
    radial-gradient(circle at 92% 8%, rgba(34, 197, 94, .14), transparent 26%),
    linear-gradient(180deg, #020617 0%, #0b1120 100%);
  color: var(--text);
  line-height: 1.55;
}

a { color: inherit; }

code {
  padding: 2px 6px;
  border-radius: 8px;
  background: rgba(148, 163, 184, 0.13);
  color: #bae6fd;
}

.topbar,
.footer,
.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

body.workspace-open .topbar,
body.workspace-open .footer,
body.workspace-open .shell {
  width: min(100%, calc(100% - 18px));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 0 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.logo {
  width: 38px;
  height: 38px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #00111c;
  box-shadow: 0 12px 28px rgba(56, 189, 248, .2);
}

.nav {
  display: flex;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
}

.nav a {
  text-decoration: none;
}

.shell {
  padding: 10px 0 36px;
}

.hero {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: start;
  margin: 8px 0 18px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: linear-gradient(135deg, rgba(15, 23, 42, .82), rgba(2, 6, 23, .72));
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
}

.hero::after {
  content: "";
  position: absolute;
  inset: auto -80px -120px auto;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: rgba(56, 189, 248, .13);
  filter: blur(10px);
}

@media (min-width: 760px) {
  .hero { grid-template-columns: minmax(0, 1.2fr) minmax(300px, 360px); }
}

.hero-side {
  display: grid;
  gap: 12px;
  position: relative;
  z-index: 1;
  align-content: start;
  width: 100%;
}

@media (min-width: 760px) {
  .hero-side {
    justify-self: end;
    max-width: 360px;
  }
}

.hero-copy {
  position: relative;
  z-index: 1;
  max-width: 680px;
}

.eyebrow {
  color: var(--accent);
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0 0 8px;
  font-size: 13px;
}

h1 {
  margin: 0;
  font-size: clamp(34px, 6vw, 56px);
  line-height: .98;
  letter-spacing: -0.055em;
}

.subtitle {
  max-width: 58ch;
  color: var(--muted);
  margin: 14px 0 0;
  font-size: 15px;
}

.hero-points {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.hero-points span {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(56, 189, 248, .22);
  background: rgba(15, 23, 42, .72);
  color: #bae6fd;
  font-size: 12px;
  font-weight: 800;
}

.hero-stats {
  position: relative;
  z-index: 1;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(2, 6, 23, .62);
}

.hero-stats span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.hero-stats strong {
  display: block;
  font-size: 38px;
  line-height: 1;
  margin-top: 6px;
}

.auth-panel {
  padding: 16px;
  border: 1px solid rgba(56, 189, 248, .24);
  border-radius: 20px;
  background:
    linear-gradient(145deg, rgba(8, 47, 73, .52), rgba(2, 6, 23, .78));
  box-shadow: 0 14px 38px rgba(0, 0, 0, .22);
}

.auth-kicker {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #7dd3fc;
}

.auth-panel h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.04em;
}

.auth-status-text {
  margin: 10px 0 6px;
  font-weight: 800;
  color: #f8fafc;
  font-size: 15px;
}

.auth-detail-text {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.auth-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 14px;
}

.auth-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
}

.status-badge.success {
  color: #052e16;
  background: rgba(34, 197, 94, .9);
}

.status-badge.warning {
  color: #422006;
  background: rgba(251, 191, 36, .92);
}

.status-badge.danger {
  color: #4c0519;
  background: rgba(251, 113, 133, .92);
}

.status-badge.muted {
  color: var(--muted);
  background: rgba(148, 163, 184, .08);
  border-color: var(--line);
}

.auth-message {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(251, 191, 36, .24);
  background: rgba(148, 163, 184, .08);
  color: #e2e8f0;
  font-size: 13px;
}

.auth-message.error {
  border-color: rgba(251, 113, 133, .34);
  background: rgba(127, 29, 29, .24);
  color: #fecdd3;
}

.auth-message.info {
  border-color: rgba(56, 189, 248, .26);
  background: rgba(8, 47, 73, .34);
  color: #bae6fd;
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

@media (min-width: 860px) {
  .toolbar { grid-template-columns: minmax(280px, 520px) 1fr; }
}

.search-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  background: rgba(15, 23, 42, .76);
  border-radius: 18px;
  padding: 0 14px;
}

.search-wrap span {
  color: var(--muted);
  font-size: 20px;
}

input[type="search"] {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 15px 0;
  outline: none;
  font-size: 15px;
}

.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  border: 1px solid var(--line);
  background: rgba(15, 23, 42, .72);
  color: var(--muted);
  border-radius: 999px;
  padding: 9px 12px;
  cursor: pointer;
  font-weight: 800;
  font-size: 13px;
}

.chip.active {
  color: #00111c;
  background: var(--accent);
  border-color: var(--accent);
}

.tool-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

@media (min-width: 720px) {
  .tool-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1080px) {
  .tool-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.tool-card {
  min-height: 210px;
  border: 1px solid var(--line);
  border-radius: 26px;
  padding: 18px;
  background:
    linear-gradient(145deg, rgba(17, 24, 39, .94), rgba(2, 6, 23, .86));
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease, background .18s ease, box-shadow .18s ease;
  box-shadow: 0 16px 42px rgba(0, 0, 0, .22);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.tool-card:hover {
  transform: translateY(-4px);
  border-color: rgba(56, 189, 248, .64);
  box-shadow: 0 22px 62px rgba(0, 0, 0, .33);
}

.tool-card.locked {
  border-style: dashed;
}

.tool-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  font-size: 24px;
  border-radius: 18px;
  background: rgba(56, 189, 248, .12);
  border: 1px solid rgba(56, 189, 248, .22);
  margin-bottom: 14px;
}

.tool-card h3 {
  margin: 0 0 8px;
  font-size: 19px;
  letter-spacing: -0.03em;
}

.tool-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.card-foot {
  margin-top: 18px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: end;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  font-size: 12px;
  color: #bae6fd;
  background: rgba(56, 189, 248, .12);
  border: 1px solid rgba(56, 189, 248, .25);
  border-radius: 999px;
  padding: 3px 8px;
}

.launch {
  color: var(--accent);
  font-weight: 900;
  white-space: nowrap;
  font-size: 13px;
}

.empty-card {
  grid-column: 1 / -1;
  min-height: 180px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: 26px;
  background: rgba(15, 23, 42, .58);
}

.workspace-view {
  animation: fadeIn .18s ease;
  width: 100%;
}

.workspace-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: center;
  padding: 14px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(2, 6, 23, .84);
  backdrop-filter: blur(18px);
  box-shadow: 0 18px 48px rgba(0, 0, 0, .28);
}

body.workspace-open .workspace-bar {
  padding-inline: 18px;
  border-radius: 28px;
}

@media (min-width: 760px) {
  .workspace-bar {
    grid-template-columns: auto 1fr auto;
  }
}

.back-button,
.button {
  min-height: 40px;
  padding: 10px 14px;
  border-radius: 15px;
  font-weight: 900;
  font-size: 14px;
  cursor: pointer;
}

.back-button {
  border: 1px solid var(--line);
  background: rgba(148, 163, 184, .08);
  color: var(--text);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
}

.button.primary {
  color: #00111c;
  background: linear-gradient(135deg, var(--accent), #7dd3fc);
  border-color: rgba(125, 211, 252, .64);
}

.button.ghost {
  border: 1px solid var(--line);
  color: var(--text);
  background: rgba(148, 163, 184, .08);
}

.workspace-title p {
  margin: 0 0 2px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 900;
}

.workspace-title h2 {
  margin: 0;
  font-size: clamp(22px, 4vw, 34px);
  letter-spacing: -0.04em;
}

.workspace-actions {
  display: flex;
  justify-content: flex-start;
}

.tool-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 14px;
}

.tool-stage {
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(2, 6, 23, .62);
  box-shadow: var(--shadow);
  overflow: hidden;
}

body.workspace-open .tool-stage {
  border-radius: 30px;
}

.tool-frame {
  display: block;
  width: 100%;
  min-height: 860px;
  height: 86vh;
  border: 0;
  background: #020617;
}

body.workspace-open .tool-frame {
  min-height: calc(100vh - 170px);
}

.footer {
  color: var(--muted);
  font-size: 13px;
  padding: 12px 0 28px;
}

.hidden { display: none !important; }

@media (max-width: 560px) {
  .topbar,
  .footer,
  .shell {
    width: min(100%, calc(100% - 20px));
  }

  .hero {
    padding: 18px;
    border-radius: 24px;
  }

  h1 {
    font-size: 34px;
  }

  .hero-points {
    gap: 6px;
  }

  .hero-points span {
    min-height: 30px;
    padding: 0 10px;
  }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
