:root {
  color-scheme: dark;
  --bg: #161719;
  --panel: #242528;
  --panel-2: #303237;
  --line: #3d4148;
  --text: #f4f1ec;
  --muted: #a8adb5;
  --accent: #8ac28f;
  --accent-2: #e0b15f;
  --danger: #d96b65;
  --shadow: 0 18px 44px rgba(0, 0, 0, .35);
  font-family: Inter, Segoe UI, system-ui, -apple-system, BlinkMacSystemFont, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(138, 194, 143, .08), transparent 34%),
    linear-gradient(225deg, rgba(224, 177, 95, .08), transparent 32%),
    var(--bg);
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px 22px 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 8px;
  background: #3b2f2a;
  color: #f4c37a;
  font-weight: 900;
  font-size: 32px;
  line-height: 1;
}

.brand strong,
.brand > div > span {
  display: block;
}

.brand strong {
  font-size: 18px;
}

.brand > div > span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.ghost-link,
.link-button {
  text-decoration: none;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.shell {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 18px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 22px 36px;
}

.gate-shell {
  display: grid;
  min-height: calc(100vh - 88px);
  place-items: center;
  padding: 18px 22px 36px;
}

.gate-card {
  width: min(100%, 420px);
}

.gate-form {
  display: grid;
  gap: 14px;
}

.gate-error {
  padding: 10px 12px;
  border: 1px solid rgba(217, 107, 101, .36);
  border-radius: 8px;
  background: rgba(217, 107, 101, .14);
  color: #ffb1ac;
  font-size: 14px;
}

.tool-panel,
.log-panel {
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 8px;
  background: rgba(36, 37, 40, .92);
  box-shadow: var(--shadow);
}

.tool-panel {
  padding: 20px;
}

.download-panel {
  min-height: 360px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

h1,
h2,
p {
  margin: 0;
}

h1,
h2 {
  font-size: 22px;
  line-height: 1.2;
}

.panel-head p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.status-pill {
  align-self: flex-start;
  min-width: 94px;
  padding: 7px 10px;
  border-radius: 999px;
  background: #37393e;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
  font-weight: 700;
}

.status-pill.ok {
  background: rgba(138, 194, 143, .18);
  color: #baf0bd;
}

.status-pill.bad {
  background: rgba(217, 107, 101, .18);
  color: #ffb1ac;
}

.auth-grid,
.download-form {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 7px;
}

.field span {
  color: #d8dbe0;
  font-size: 13px;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #17181a;
  color: var(--text);
  outline: none;
}

input {
  min-height: 48px;
  padding: 0 14px;
}

textarea {
  min-height: 96px;
  resize: vertical;
  padding: 12px 14px;
}

input:focus,
textarea:focus {
  border-color: rgba(138, 194, 143, .9);
  box-shadow: 0 0 0 3px rgba(138, 194, 143, .14);
}

.button-row,
.format-row,
.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.check-row {
  min-height: 42px;
  padding: 0 2px;
  color: #d8dbe0;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.check-row input {
  width: 20px;
  min-height: 20px;
  height: 20px;
  accent-color: var(--accent);
  cursor: pointer;
}

button,
.link-button,
.ghost-link {
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}

button:hover,
.link-button:hover,
.ghost-link:hover {
  transform: translateY(-1px);
}

button:disabled {
  cursor: wait;
  opacity: .64;
  transform: none;
}

.primary,
.secondary,
.ghost-link,
.link-button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 0 15px;
  font-weight: 800;
}

.primary {
  background: var(--accent);
  color: #122016;
}

.secondary,
.ghost-link,
.link-button {
  border-color: rgba(255, 255, 255, .1);
  background: #32343a;
  color: var(--text);
}

.download-button {
  min-height: 52px;
  font-size: 16px;
}

.format-row {
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #191a1d;
}

.format {
  flex: 1;
  min-height: 42px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
}

.format.active {
  background: #435745;
  color: #e9ffe8;
}

.session-meta {
  min-height: 20px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.progress-wrap {
  margin-top: 20px;
}

.progress-bar {
  overflow: hidden;
  height: 10px;
  border-radius: 999px;
  background: #151619;
}

.progress-bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .2s ease;
}

.progress-text {
  margin-top: 9px;
  color: var(--muted);
  font-size: 14px;
}

.book-preview {
  display: grid;
  gap: 8px;
  margin-top: 20px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 8px;
  background: var(--panel-2);
}

.book-preview strong {
  font-size: 18px;
}

.book-preview span {
  color: var(--muted);
  font-size: 14px;
}

.log-panel {
  grid-column: 1 / -1;
  overflow: hidden;
}

.log-head {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.icon-button {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
}

.log {
  max-height: 210px;
  overflow: auto;
  padding: 12px 16px 16px;
  color: #d5d7dc;
  font: 13px/1.55 Consolas, Menlo, monospace;
}

.log div {
  padding: 3px 0;
}

.log .error {
  color: #ffb1ac;
}

.log .ok {
  color: #baf0bd;
}

@media (max-width: 860px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .topbar,
  .shell {
    padding-left: 14px;
    padding-right: 14px;
  }
}

@media (max-width: 520px) {
  .topbar {
    align-items: flex-start;
  }

  .panel-head {
    display: grid;
  }

  .primary,
  .secondary,
  .link-button {
    width: 100%;
  }
}
