:root {
  color-scheme: dark;
  --bg: #12110f;
  --surface: #1f2421;
  --surface-strong: #29312d;
  --line: #41483d;
  --text: #f4f1e8;
  --muted: #b7b3a5;
  --accent: #d6a84f;
  --accent-strong: #f0c866;
  --green: #7fb069;
  --danger: #d16363;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(rgba(18, 17, 15, 0.78), rgba(18, 17, 15, 0.93)),
    url("https://images.unsplash.com/photo-1518709268805-4e9042af2176?auto=format&fit=crop&w=1800&q=80") center / cover fixed;
  color: var(--text);
}

button,
input {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 32px;
}

.workspace {
  width: min(1180px, 100%);
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

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

.profile-name {
  max-width: 220px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-strong);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 3.8rem, 4.5rem);
  line-height: 0.95;
}

h2 {
  margin-bottom: 0;
  font-size: 1.35rem;
}

h3 {
  margin-bottom: 0;
  font-size: 2rem;
  overflow-wrap: anywhere;
}

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.panel {
  border: 1px solid color-mix(in srgb, var(--line), transparent 18%);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface), transparent 8%);
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(14px);
}

.create-panel {
  padding: 22px;
}

.viewer-panel {
  padding: 22px;
}

.section-heading {
  margin-bottom: 18px;
}

.character-form {
  display: grid;
  gap: 10px;
}

.character-form.is-disabled {
  opacity: 0.72;
}

label {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

input {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(8, 9, 8, 0.6);
  color: var(--text);
  padding: 12px 14px;
  outline: none;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(214, 168, 79, 0.18);
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #1b1710;
  cursor: pointer;
  font-weight: 800;
  padding: 12px 16px;
}

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

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

.icon-button {
  width: 44px;
  height: 44px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  background: rgba(31, 36, 33, 0.82);
  color: var(--text);
  font-size: 1.35rem;
}

.form-note,
.list-message,
.empty-state p {
  color: var(--muted);
}

.form-note {
  margin-bottom: 0;
  font-size: 0.88rem;
}

.viewer-grid {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(0, 1fr);
  gap: 14px;
  min-height: 360px;
}

.character-list {
  border-right: 1px solid var(--line);
  padding-right: 14px;
}

.list-stack {
  display: grid;
  gap: 8px;
}

.list-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  border: 1px solid var(--line);
  background: rgba(8, 9, 8, 0.34);
  color: var(--text);
  text-align: left;
}

.list-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-item small {
  flex: 0 0 auto;
  color: var(--muted);
}

.list-item.is-selected {
  border-color: var(--accent);
  background: rgba(214, 168, 79, 0.14);
}

.character-card {
  min-height: 100%;
  display: grid;
  align-content: start;
  gap: 24px;
  padding: 10px 0 0;
}

.character-header {
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
}

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

.stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 9, 8, 0.32);
  padding: 18px;
}

.stat dt {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
  text-transform: uppercase;
}

.stat dd {
  margin: 0;
  color: var(--green);
  font-size: 2.4rem;
  font-weight: 900;
  line-height: 1;
}

.empty-state {
  min-height: 260px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 24px;
  text-align: center;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: min(420px, calc(100vw - 48px));
  transform: translateY(18px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #252a26;
  color: var(--text);
  opacity: 0;
  padding: 12px 14px;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

code {
  color: var(--accent-strong);
}

@media (max-width: 820px) {
  .app-shell {
    padding: 20px;
  }

  .layout,
  .viewer-grid {
    grid-template-columns: 1fr;
  }

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

  .account-bar {
    justify-content: flex-start;
    width: 100%;
  }

  .character-list {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding-right: 0;
    padding-bottom: 14px;
  }
}

@media (max-width: 520px) {
  .input-row {
    grid-template-columns: 1fr;
  }

  .stat-grid {
    grid-template-columns: 1fr;
  }
}
