:root {
  color-scheme: light;
  --bg: #eef2f6;
  --panel: #ffffff;
  --panel-alt: #f6f8fb;
  --border: #d4dde7;
  --text: #15202b;
  --muted: #667789;
  --accent: #0f6cbd;
  --accent-strong: #084f8a;
  --danger: #c73e1d;
  --shadow: 0 18px 44px rgba(20, 42, 66, 0.08);
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --sans: "Segoe UI", "PingFang SC", "Noto Sans SC", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #fafcfe 0%, var(--bg) 100%);
  color: var(--text);
  font-family: var(--sans);
}

.page {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 22px;
}

.topbar h1 {
  margin: 0 0 8px;
  font-size: 30px;
  line-height: 1.15;
}

.topbar p {
  margin: 0;
  max-width: 760px;
  color: var(--muted);
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.meta span {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--muted);
  font-size: 13px;
}

.dashboard,
.stack,
.account-form {
  display: grid;
  gap: 16px;
}

.auth-card,
.panel,
.action-panel {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-card {
  width: min(460px, 100%);
  padding: 24px;
}

.auth-card h2,
.panel h2 {
  margin: 0;
  font-size: 18px;
}

.stack {
  margin-top: 18px;
}

.action-panel {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) max-content max-content max-content;
  gap: 12px;
  align-items: end;
  padding: 16px;
}

.account-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.account-form {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) max-content;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-alt);
}

label {
  display: grid;
  gap: 6px;
}

label span {
  color: var(--muted);
  font-size: 13px;
}

input,
select {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

button {
  min-height: 42px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 0 18px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

button.secondary {
  border-color: var(--border);
  background: var(--panel-alt);
  color: var(--text);
}

button.secondary:hover {
  border-color: var(--accent);
  background: #edf5fc;
}

button:disabled {
  opacity: 0.66;
  cursor: wait;
}

.app-dropdown {
  position: relative;
}

.dropdown-button {
  width: 100%;
  justify-content: flex-start;
  color: var(--text);
}

.dropdown-panel {
  position: absolute;
  z-index: 30;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  box-shadow: var(--shadow);
}

.app-checklist {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
  padding: 10px;
}

.app-check {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 34px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
}

.app-check:hover {
  background: var(--panel-alt);
}

.app-check input {
  width: 18px;
  min-height: 18px;
  height: 18px;
  margin: 0;
}

.app-check span {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 14px;
}

.copy-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.copy-btn {
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
}

.panel {
  padding: 18px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 12px;
}

.panel-header span {
  color: var(--muted);
  font-size: 13px;
}

pre,
.saved-meta {
  margin: 0;
  padding: 14px;
  background: #0e1721;
  color: #dae7f5;
  border: 1px solid #162435;
  border-radius: 6px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
}

#resultText {
  min-height: 180px;
  max-height: 420px;
}

.saved-apps {
  display: grid;
  gap: 12px;
}

.saved-app {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-alt);
  overflow: hidden;
}

.saved-app summary {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 13px 14px;
  cursor: pointer;
}

.saved-app summary span {
  font-weight: 600;
}

.saved-app summary small {
  color: var(--muted);
}

.saved-meta {
  border-radius: 0;
  border-left: 0;
  border-right: 0;
}

.saved-app .copy-actions {
  padding: 0 14px 12px;
  margin-bottom: 0;
}

.warning-block {
  background: #3b1d12;
  color: #ffd7c7;
  border-color: #6f321e;
  border-radius: 0;
}

.empty {
  margin: 0;
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  min-width: 200px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 6px;
  background: #10243a;
  color: #fff;
  box-shadow: var(--shadow);
}

.toast.error {
  background: var(--danger);
}

.hidden {
  display: none !important;
}

@media (max-width: 820px) {
  .page {
    width: min(100vw - 24px, 720px);
    padding-top: 18px;
  }

  .topbar,
  .panel-header,
  .saved-app summary {
    flex-direction: column;
    align-items: flex-start;
  }

  .action-panel,
  .account-grid,
  .account-form {
    grid-template-columns: 1fr;
  }

  button {
    width: 100%;
  }
}
