:root {
  --page: #ece6da;
  --sidebar: #e4ddd0;
  --paper: #f3eee4;
  --chip: #efe8db;
  --ink: #2c2824;
  --mute: #6f6a62;
  --line: #d4cdc0;
  --hover: #ddd5c6;
  --accent: #6d28d9;
  --accent-soft: #e8dcf6;
  --accent-line: #d4c4ea;
  --accent-ink: #4c1d95;
  --ok: #0f7b6c;
  --err: #b4534b;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(44, 40, 36, 0.05), 0 10px 28px rgba(109, 40, 217, 0.08);
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: var(--page);
  color: var(--ink);
}

body {
  font-family: "Plus Jakarta Sans", "Noto Sans TC", sans-serif;
  font-size: 0.95rem;
  line-height: 1.55;
}

a {
  color: var(--accent);
  text-underline-offset: 0.18em;
}

a:hover { color: var(--accent-ink); }

.ico {
  display: inline-block;
  width: 1em;
  height: 1em;
  flex: 0 0 auto;
  background: currentColor;
  -webkit-mask: var(--ico) center / contain no-repeat;
  mask: var(--ico) center / contain no-repeat;
  vertical-align: -0.12em;
}

[data-ico="download"] { --ico: url("/icon-download.svg"); }
[data-ico="upload"] { --ico: url("/icon-upload.svg"); }
[data-ico="version"] { --ico: url("/icon-version.svg"); }
[data-ico="discord"] { --ico: url("/icon-discord.svg"); }
[data-ico="shield"] { --ico: url("/icon-shield.svg"); }
[data-ico="link"] { --ico: url("/icon-link.svg"); }

.app {
  display: grid;
  grid-template-columns: minmax(22rem, 38vw) 1fr;
  height: 100dvh;
  overflow: hidden;
}

.pane-ops {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  height: 100dvh;
  min-height: 0;
  padding: 0.7rem 0.8rem 0.65rem;
  overflow: hidden;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  overscroll-behavior: contain;
}

.pane-docs {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 0;
  overflow: auto;
  padding: 0.7rem 0.85rem 0.7rem;
  background: var(--paper);
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #c8c0b2 transparent;
}

.pane-docs::-webkit-scrollbar { width: 0.55rem; }
.pane-docs::-webkit-scrollbar-thumb {
  background: #c8c0b2;
  border-radius: 99px;
}

.mast {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.22rem;
  flex: 0 0 auto;
  text-align: center;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
}

.logo {
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 0.5rem;
}

.crumb {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--mute);
}

.crumb span {
  margin: 0 0.2rem;
  font-weight: 500;
  color: #b0aaa0;
}

h1 {
  margin: 0;
  font-weight: 800;
  font-size: clamp(1.22rem, 1.7vw, 1.48rem);
  letter-spacing: -0.035em;
  line-height: 1.22;
  text-align: center;
  color: var(--ink);
}

.lede {
  margin: 0;
  color: var(--mute);
  font-size: 0.84rem;
}

.links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem;
  margin-top: 0.15rem;
}

.links a {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.28rem 0.6rem;
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  text-decoration: none;
  font-size: 0.78rem;
  font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--line);
}

.links a:hover {
  background: var(--accent-soft);
  color: var(--accent-ink);
  box-shadow: inset 0 0 0 1px var(--accent-line);
}

.shell {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--paper);
  height: 100%;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 0.7rem 0.75rem;
  border-radius: 12px;
  box-shadow: var(--shadow);
  scrollbar-width: thin;
  scrollbar-color: #c8c0b2 transparent;
}

.callout {
  display: flex;
  flex-direction: column;
  gap: 0.08rem;
  margin-bottom: 0.5rem;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  background: var(--accent-soft);
}

.kicker {
  margin: 0;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--accent-ink);
}

.callout b {
  font-size: 1.45rem;
  letter-spacing: -0.04em;
  color: var(--accent);
  font-weight: 800;
}

.plate span, .callout span, .hint, .msg, .status-line {
  color: var(--mute);
  font-size: 0.78rem;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
}

.btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: 100%;
  padding: 0.68rem 0.75rem;
  border-radius: var(--radius);
  background: var(--accent);
  color: #f3eee4;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  text-decoration: none;
  transition: transform 0.2s var(--ease), background 0.2s var(--ease);
}

.btn:hover { background: #5b21b6; color: #f3eee4; }
.btn:active { transform: scale(0.98); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

.btn-ghost {
  background: var(--paper);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
}

.btn-ghost:hover {
  background: var(--hover);
  color: var(--ink);
}

.row {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  gap: 0.4rem;
  margin-top: 0.55rem;
  min-height: 0;
}

label {
  display: grid;
  gap: 0.24rem;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--ink);
}

.row > label:last-of-type {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

input[type="text"], .file {
  width: 100%;
  border: 0;
  background: var(--sidebar);
  color: var(--ink);
  padding: 0.55rem 0.7rem;
  font: inherit;
  font-weight: 500;
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px var(--line);
}

input[type="text"]:focus {
  outline: none;
  background: var(--paper);
  box-shadow: inset 0 0 0 1.5px var(--accent);
}

.file {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 auto;
  min-height: 4.5rem;
  color: var(--mute);
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='8' height='8'><rect width='8' height='8' fill='none' stroke='%23c8c0b2' stroke-width='1' stroke-dasharray='2 2'/></svg>");
}

.file:hover {
  background-color: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent-line);
}

.file input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.progress {
  height: 0.28rem;
  background: var(--sidebar);
  overflow: hidden;
  display: none;
  border-radius: 99px;
}

.progress > i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
}

.msg[data-tone="ok"] { color: var(--ok); }
.msg[data-tone="err"] { color: var(--err); }

.docs {
  display: grid;
  flex: 1 1 auto;
  gap: 0.55rem 0.65rem;
  align-content: stretch;
  min-height: 100%;
}

.block {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  background: var(--chip);
  box-shadow: inset 0 0 0 1px var(--line);
}

.block-accent {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent-line);
}

.docs h2 {
  margin: 0 0 0.4rem;
  font-size: 0.98rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.docs ul {
  margin: 0.1rem 0 0;
  padding-left: 1.1rem;
}

.docs ol {
  margin: 0.1rem 0 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.docs ol li {
  position: relative;
  margin: 0.28rem 0;
  padding-left: 1.85rem;
}

.docs ol li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0.08rem;
  width: 1.3rem;
  height: 1.3rem;
  border-radius: 999px;
  background: var(--chip);
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 800;
  display: grid;
  place-items: center;
  box-shadow: inset 0 0 0 1px var(--accent-line);
}

.block-accent ol li::before {
  background: var(--chip);
}

.docs ul li { margin: 0.2rem 0; }

.foot {
  margin-top: 0;
  padding: 0.35rem 0.15rem 0;
  color: var(--mute);
  font-size: 0.78rem;
}

@media (min-width: 1100px) {
  .docs {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto 1fr 1fr auto;
    height: 100%;
  }

  .span-all {
    grid-column: 1 / -1;
  }
}

@media (max-width: 860px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1.25fr) minmax(0, 0.75fr);
  }

  .pane-ops,
  .pane-docs {
    height: auto;
    min-height: 0;
    overflow: auto;
  }

  .pane-ops {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 0.65rem 0.7rem;
  }

  .pane-docs { padding: 0.65rem 0.7rem 0.75rem; }

  .docs {
    min-height: 0;
    align-content: start;
  }

  .actions { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .btn { transition: none; }
}
