:root {
  --cell: #0f2a44;
  --cell-2: #173d62;
  --sun: #f5a524;
  --sun-deep: #e08e0b;
  --sky: #edf1f5;
  --card: #ffffff;
  --ink: #14212e;
  --muted: #5e6e80;
  --line: #dce3eb;
  --field: #f7f9fb;
  --blue: #1f5faf;
  --pending: #b4412f;
  --band: 250px;
  --panel-grid:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.06) 0 1px, transparent 1px 64px),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.06) 0 1px, transparent 1px 40px);
  color: var(--ink);
  font-family: "Noto Sans SC", "PingFang SC", sans-serif;
  background: var(--sky);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  line-height: 1.5;
}

body.app {
  visibility: hidden;
  background:
    radial-gradient(640px 260px at 86% 0, rgba(245, 165, 36, 0.3), transparent 70%) top / 100% var(--band) no-repeat,
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.06) 0 1px, transparent 1px 64px) top / 100% var(--band) no-repeat,
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.06) 0 1px, transparent 1px 40px) top / 100% var(--band) no-repeat,
    linear-gradient(160deg, var(--cell), var(--cell-2)) top / 100% var(--band) no-repeat,
    var(--sky);
}
body.app.ready { visibility: visible; }

.top, .nav, .lead, main {
  width: min(1160px, calc(100% - 40px));
  margin-left: auto;
  margin-right: auto;
}

.top {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  padding: 26px 0 18px;
  color: #fff;
}

.eyebrow {
  margin: 0 0 4px;
  letter-spacing: 0.24em;
  font-size: 12px;
  font-weight: 700;
  color: var(--sun);
}

h1, h2, h3 { margin: 0; }
h1 { font-family: "Noto Serif SC", serif; font-weight: 600; font-size: 30px; letter-spacing: 0.08em; }
h2 { font-size: 19px; font-weight: 700; letter-spacing: 0.02em; }

.top-side { display: flex; align-items: center; gap: 8px; }
.quit {
  padding: 9px 16px;
  border-radius: 999px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: rgba(255, 255, 255, 0.72);
  font-size: 14px;
  transition: background 0.2s, color 0.2s;
}
.quit:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.who {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 8px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.2s, color 0.2s;
}
.who::before {
  content: "";
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background:
    linear-gradient(90deg, transparent 48%, rgba(15, 42, 68, 0.35) 48% 52%, transparent 52%),
    linear-gradient(0deg, transparent 48%, rgba(15, 42, 68, 0.35) 48% 52%, transparent 52%),
    var(--sun);
}
.who small { font-size: 12px; color: rgba(255, 255, 255, 0.6); }
.who:hover { background: rgba(255, 255, 255, 0.14); }
.who[aria-selected="true"] { background: #fff; color: var(--cell); }
.who[aria-selected="true"] small { color: var(--muted); }

.nav {
  display: flex;
  gap: 4px;
  width: fit-content;
  max-width: calc(100% - 40px);
  margin-left: max(20px, calc((100% - 1160px) / 2));
  margin-bottom: 14px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}
.nav button {
  padding: 8px 20px;
  border-radius: 999px;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  font-weight: 500;
  transition: background 0.2s, color 0.2s;
}
.nav button:hover { color: #fff; }
.nav button[aria-selected="true"] { background: #fff; color: var(--cell); }

.lead {
  margin-top: 0;
  margin-bottom: 20px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
}

main { padding-bottom: 56px; }

.view {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}
.view[hidden] { display: none; }

.sheet {
  background: var(--card);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 1px 2px rgba(15, 42, 68, 0.06), 0 14px 36px rgba(15, 42, 68, 0.1);
}

.sheet-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.kicker {
  display: inline-block;
  margin: 0 0 6px;
  padding: 2px 10px;
  border-radius: 999px;
  background: #fff3dc;
  color: #94580a;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

textarea, button, input { font: inherit; }
button { border: 0; cursor: pointer; }

input[type="text"], input[type="password"], input[type="search"], input:not([type]), textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--field);
  color: var(--ink);
  padding: 11px 14px;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
textarea { resize: vertical; line-height: 1.7; }
input:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(31, 95, 175, 0.16);
}
button:focus-visible, .drop:focus-within {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
}

.primary {
  padding: 11px 22px;
  border-radius: 10px;
  background: var(--sun);
  color: var(--cell);
  font-weight: 700;
  box-shadow: 0 6px 16px rgba(245, 165, 36, 0.32);
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
}
.primary:hover { background: var(--sun-deep); transform: translateY(-1px); }
.primary:disabled { opacity: 0.55; cursor: wait; transform: none; box-shadow: none; }

.text {
  padding: 0;
  background: transparent;
  color: var(--blue);
  font-weight: 500;
}
.text:hover { text-decoration: underline; text-underline-offset: 3px; }

.danger {
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid var(--pending);
  background: transparent;
  color: var(--pending);
  font-weight: 500;
  transition: background 0.2s, color 0.2s;
}
.danger:hover { background: var(--pending); color: #fff; }

.summary, .status, .fine, .usage, .prompt-label {
  color: var(--muted);
  font-size: 14px;
}
.summary { margin: 0 0 16px; line-height: 1.7; min-height: 3.4em; }
.status, .usage { margin: 0; }
.fine { margin: 10px 0 0; font-size: 13px; line-height: 1.6; }
.prompt-label { display: block; margin: 16px 0 8px; font-weight: 500; color: #3d4c5c; }

.check {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-top: 16px;
  font-size: 14px;
  color: var(--muted);
}
.check input { margin-top: 4px; accent-color: var(--blue); }
.check a { color: var(--blue); text-decoration: none; }
.check a:hover { text-decoration: underline; }

.subhead { margin: 8px 0 0; font-size: 15px; font-weight: 700; }
.danger-block {
  margin-top: 28px;
  padding: 16px 18px 18px;
  border-radius: 12px;
  background: #fdf3f1;
}
.danger-block .subhead { margin: 0; color: var(--pending); }
.danger-block .prompt-label { margin-top: 8px; }
.danger-block input { background: #fff; }

.history-item {
  padding: 14px 16px;
  margin-bottom: 10px;
  border-radius: 12px;
  background: var(--field);
  border: 1px solid var(--line);
}
.history-item p { margin: 4px 0 0; }
.history-item .text { margin-top: 8px; font-size: 14px; }
.review-item {
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #f1f8f3;
  border: 1px solid #b7d7c1;
}
.review-item.blocked { background: #fdf3f1; border-color: #e8b4ab; }
.review-meta { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; color: var(--muted); }
.review-item p { margin: 6px 0 0; }
.review-item.blocked strong { color: var(--pending); }
.review-item:not(.blocked) strong { color: #1f6b3a; }
.span-2 { grid-column: 1 / -1; }
.keyword-tools, .keyword-add { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.keyword-tools input, .keyword-add input { flex: 1; width: auto; min-width: 160px; }
.keyword-tools input[type="search"] { appearance: none; -webkit-appearance: none; }
.keyword-tools select, .keyword-add select, .keyword-row select {
  flex: none;
  width: 220px;
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  line-height: 1.5;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  background-color: var(--field);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%235e6e80' d='M1.2.8 6 5.6 10.8.8 12 2 6 8 0 2z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 12px 8px;
  padding: 11px 40px 11px 14px;
  transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}
.keyword-tools select:focus, .keyword-add select:focus, .keyword-row select:focus {
  outline: none;
  border-color: var(--blue);
  background-color: #fff;
  box-shadow: 0 0 0 3px rgba(31, 95, 175, 0.16);
}
.keyword-add .primary { flex: none; padding: 11px 16px; }
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.tag-list .fine { margin: 0; }
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 4px 10px 4px 12px;
  border-radius: 999px;
  background: var(--field);
  border: 1px solid var(--line);
  font-size: 14px;
}
.keyword-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px auto;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.keyword-row select { width: 100%; }
.pager { display: flex; align-items: center; gap: 14px; margin-top: 12px; color: var(--muted); font-size: 13px; }
.pager button:disabled { opacity: 0.35; cursor: default; text-decoration: none; }
.history-item img { display: block; width: min(100%, 360px); margin-top: 10px; border-radius: 8px; }

dl {
  margin: 0;
  display: grid;
  grid-template-columns: 88px 1fr;
  border-top: 1px solid var(--line);
}
dt, dd { padding: 10px 0; border-bottom: 1px solid var(--line); }
dt { color: var(--muted); font-size: 14px; }
dd { margin: 0; font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 14px; }
dd.empty { color: var(--pending); }

.block { margin-top: 18px; }
.block h3 { margin: 0 0 6px; font-size: 14px; font-weight: 700; color: #3d4c5c; }
.block ul { margin: 0; padding-left: 18px; }
.block li { margin: 4px 0; line-height: 1.6; }

.demos {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}
.demos button {
  padding: 0;
  overflow: hidden;
  border-radius: 10px;
  border: 2px solid transparent;
  background: var(--field);
  text-align: left;
  color: var(--muted);
  font-size: 13px;
  box-shadow: 0 0 0 1px var(--line);
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.demos button:hover { transform: translateY(-2px); box-shadow: 0 8px 18px rgba(15, 42, 68, 0.12); }
.demos button[aria-pressed="true"] { border-color: var(--sun); color: var(--ink); font-weight: 500; box-shadow: 0 6px 16px rgba(245, 165, 36, 0.25); }
.demos img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.demos span { display: block; padding: 6px 10px; }

.drop {
  display: grid;
  place-items: center;
  min-height: 210px;
  border: 1.5px dashed #c3cfdc;
  border-radius: 12px;
  background: var(--field);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  color: var(--muted);
  transition: border-color 0.2s, background 0.2s;
}
.drop:hover { border-color: var(--blue); background: #f1f6fc; }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop img, .frame img { width: 100%; height: 100%; object-fit: cover; }
#drop-label { display: grid; justify-items: center; gap: 10px; font-size: 14px; }
#drop-label::before {
  content: "+";
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  color: var(--blue);
  font-size: 22px;
  box-shadow: 0 2px 8px rgba(15, 42, 68, 0.1);
}
#drop-label[hidden] { display: none; }

.stamp {
  margin: 0;
  padding: 3px 10px;
  border: 1.5px solid var(--pending);
  border-radius: 6px;
  color: var(--pending);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.14em;
  transform: rotate(-6deg);
}

.frame {
  min-height: 280px;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  background:
    repeating-linear-gradient(90deg, rgba(31, 95, 175, 0.07) 0 1px, transparent 1px 64px),
    repeating-linear-gradient(0deg, rgba(31, 95, 175, 0.07) 0 1px, transparent 1px 40px),
    linear-gradient(160deg, #eef3f9, #e3eaf2);
}
.frame p { margin: 0 0 8px; line-height: 1.6; color: var(--ink); font-weight: 500; }
#effect-empty { padding: 24px; }

.points { margin: 8px 0 0; padding: 0; list-style: none; text-align: left; color: var(--muted); font-size: 14px; }
.points li { margin: 6px 0; padding-left: 18px; position: relative; }
.points li::before, .gate-points li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.5em;
  width: 8px;
  height: 6px;
  border-radius: 1px;
  background: var(--sun);
}

.credit {
  margin: 16px 0 0;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  text-align: right;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 12px;
  color: var(--muted);
}

.gate { visibility: hidden; background: var(--card); }
.gate.ready { visibility: visible; }
.gate-split {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 0.95fr) minmax(320px, 1fr);
}
.gate-cover {
  background:
    radial-gradient(520px 320px at 80% 8%, rgba(245, 165, 36, 0.32), transparent 70%),
    var(--panel-grid),
    linear-gradient(160deg, var(--cell), var(--cell-2));
  color: #fff;
  padding: 64px 56px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.gate-cover h1 { font-size: 44px; line-height: 1.25; }
.lede {
  max-width: 28em;
  margin: 18px 0 0;
  line-height: 1.8;
  color: rgba(255, 255, 255, 0.76);
}
.gate-points {
  margin: 24px 0 0;
  padding: 0;
  list-style: none;
  color: rgba(255, 255, 255, 0.7);
}
.gate-points li { margin: 10px 0; padding-left: 18px; position: relative; }
.roof { width: min(300px, 100%); margin-top: 40px; }
.gate-form {
  display: grid;
  align-content: center;
  justify-items: center;
  padding: 48px 56px;
}
.gate-form form { width: min(400px, 100%); }
.gate-form .sheet-head { margin-bottom: 8px; }
.gate-form h2 { font-size: 28px; }
.gate-form .primary { width: 100%; }
.gate.ready .gate-form form { animation: form-in 0.45s ease-out both; }
.gate.ready .gate-cover > * { animation: form-in 0.5s ease-out both; }
.gate.ready .gate-cover > :nth-child(2) { animation-delay: 0.05s; }
.gate.ready .gate-cover > :nth-child(n+3) { animation-delay: 0.1s; }
@keyframes form-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
.form-lede { margin: 0 0 8px; color: var(--muted); font-size: 14px; }
.hint { margin: 6px 0 0; color: #8a97a6; font-size: 12px; }
.form-switch { margin: 24px 0 0; padding-top: 18px; border-top: 1px solid var(--line); text-align: center; color: var(--muted); font-size: 14px; }
.form-switch a { color: var(--blue); font-weight: 700; text-decoration: none; }
.form-switch a:hover { text-decoration: underline; text-underline-offset: 3px; }
.features { margin: 32px 0 0; padding: 0; list-style: none; display: grid; gap: 12px; max-width: 30em; }
.features li {
  padding: 14px 16px 14px 18px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-left: 3px solid var(--sun);
}
.features strong { display: block; color: #fff; font-size: 15px; }
.features span { display: block; margin-top: 4px; color: rgba(255, 255, 255, 0.68); font-size: 13px; line-height: 1.6; }
.gate-form .actions { flex-direction: column; align-items: stretch; margin-top: 22px; }

@media (max-width: 800px) {
  :root { --band: 300px; }
  .view { grid-template-columns: 1fr; }
  .top { align-items: flex-start; }
  .who small { display: none; }
  h1 { font-size: 24px; }
  .sheet { padding: 20px 18px; }
  .gate-split { grid-template-columns: 1fr; }
  .gate-cover { padding: 36px 24px 28px; }
  .gate-cover h1 { font-size: 32px; }
  .roof { width: 180px; margin-top: 18px; }
  .gate-form { padding: 32px 22px 48px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto; }
}
