:root {
  color-scheme: light;
  --bg: #f5f0e8;
  --surface: #fffaf3;
  --surface-strong: #f0e4d6;
  --ink: #241a15;
  --muted: #74665c;
  --line: #dfd1c2;
  --accent: #246b62;
  --accent-2: #8f2f45;
  --shadow: 0 18px 50px rgba(54, 38, 24, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

button.ghost {
  background: #eadccd;
  color: #4b382c;
}

.shell {
  width: min(100%, 1060px);
  margin: 0 auto;
  padding: 24px;
}

.login-panel,
.platform,
.panel,
.api-panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-panel {
  width: min(100%, 430px);
  margin: 10vh auto 0;
  padding: 24px;
  display: grid;
  gap: 22px;
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.1;
}

h2 {
  font-size: 18px;
}

.intro {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.45;
}

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

label {
  display: grid;
  gap: 7px;
  color: #4b382c;
  font-size: 13px;
  font-weight: 800;
}

input {
  min-height: 44px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
}

.error {
  color: #8b2f2f;
  font-size: 13px;
  font-weight: 700;
}

.platform {
  padding: 18px;
  display: grid;
  gap: 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.menu {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.menu button {
  min-height: 58px;
  padding: 8px 10px;
  background: #eadccd;
  color: #4b382c;
  text-align: left;
}

.menu button.active {
  background: var(--ink);
  color: #fff;
}

.menu span {
  display: block;
  color: currentColor;
  font-size: 11px;
  font-weight: 500;
  opacity: 0.78;
}

.content-grid {
  display: grid;
}

.panel {
  display: none;
  min-height: 290px;
  padding: 16px;
  box-shadow: none;
}

.panel.active {
  display: grid;
  align-content: start;
  gap: 14px;
}

.list {
  display: grid;
  gap: 10px;
}

.item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: #fffdf8;
}

.marketplace-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.item strong {
  display: block;
  margin-bottom: 5px;
}

.item p {
  color: var(--muted);
  line-height: 1.4;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.pill {
  border-radius: 999px;
  padding: 4px 8px;
  background: #dcebe8;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.pill.installed {
  background: #e6efe9;
  color: #246b62;
}

.install-link {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  text-decoration: none;
  white-space: nowrap;
}

.install-link:disabled {
  background: #eadccd;
  color: #74665c;
  cursor: not-allowed;
}

.install-link.installed-button {
  background: #dcebe8;
  color: #246b62;
}

.secondary-link {
  background: #eadccd;
  color: #4b382c;
}

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

.ai-provider-panel {
  grid-column: 1 / -1;
}

.provider-card {
  display: grid;
  gap: 12px;
}

.provider-title,
.provider-actions,
.provider-toggles,
.config-row {
  display: flex;
  gap: 10px;
}

.provider-title {
  align-items: flex-start;
  justify-content: space-between;
}

.provider-toggles {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.provider-toggles label {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 10px;
  background: #fffaf3;
  color: #4b382c;
  font-size: 12px;
  font-weight: 900;
}

.provider-toggles input {
  width: 16px;
  height: 16px;
}

.config-row {
  align-items: end;
}

.config-field {
  min-width: 0;
  display: grid;
  flex: 1;
  gap: 5px;
}

.config-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.config-field input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #fffdf8;
  color: var(--ink);
}

.provider-actions {
  align-items: center;
  flex-wrap: wrap;
}

.provider-actions button {
  min-height: 38px;
}

.provider-actions button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.subscription-ai {
  display: grid;
  gap: 12px;
}

.ai-choice-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.ai-choice {
  min-height: 96px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: #fffaf3;
  cursor: pointer;
}

.ai-choice.active {
  border-color: var(--accent);
  background: #eef8f5;
}

.ai-choice input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
}

.ai-choice span {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.ai-choice strong,
.ai-choice small {
  overflow-wrap: anywhere;
}

.ai-choice small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.save-state {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.api-panel {
  padding: 16px;
  box-shadow: none;
  display: grid;
  gap: 12px;
}

.startup-error {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.startup-error p {
  color: var(--muted);
}

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

code {
  min-height: 38px;
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #fffdf8;
  color: #4b382c;
  overflow-wrap: anywhere;
}

@media (max-width: 720px) {
  .shell {
    padding: 14px;
  }

  .menu,
  .endpoint-list,
  .admin-grid,
  .ai-choice-list,
  .marketplace-item,
  .provider-title,
  .config-row {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .topbar {
    align-items: flex-start;
  }
}
