:root {
  --bg-dark: #0b0f19;
  --bg-card: #151d2f;
  --bg-section: #101726;
  --border-color: #27354f;
  --border-highlight: #3b82f6;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --primary-gold: #f59e0b;
  --primary-gold-dark: #d97706;
  --accent-cyan: #38bdf8;
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --font-heading: 'Cinzel', serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-body);
  line-height: 1.5;
  min-height: 100vh;
  padding: 1.5rem;
}

.app-container {
  max-width: 1400px;
  margin: 0 auto;
}

/* Header */
.app-header {
  background: linear-gradient(180deg, #182238 0%, #111827 100%);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.25rem 1.75rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand-badge {
  background: linear-gradient(135deg, var(--primary-gold-dark) 0%, var(--primary-gold) 100%);
  color: #000;
  font-family: var(--font-heading);
  font-weight: 900;
  font-size: 1rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  letter-spacing: 0.5px;
}

h1 {
  font-family: var(--font-heading);
  font-size: 1.75rem;
  font-weight: 900;
  letter-spacing: 1.5px;
  background: linear-gradient(90deg, #ffffff 0%, var(--primary-gold) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.system-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.85rem;
  border-radius: 20px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  font-size: 0.85rem;
}

.status-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-red);
}

.status-indicator.online {
  background: var(--accent-green);
  box-shadow: 0 0 10px var(--accent-green);
}

/* Metadata Bar */
.meta-bar {
  display: flex;
  gap: 2rem;
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border-color);
  flex-wrap: wrap;
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
}

.meta-label {
  color: var(--text-muted);
}

.meta-value {
  color: var(--primary-gold);
  font-weight: 600;
}

.meta-did {
  font-family: var(--font-mono);
  background: rgba(0, 0, 0, 0.4);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  color: #cbd5e1;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Layout */
.main-layout {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 1.5rem;
}

@media (max-width: 1024px) {
  .main-layout {
    grid-template-columns: 1fr;
  }
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  margin-bottom: 1.5rem;
}

.card-header {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

.step-num {
  width: 32px;
  height: 32px;
  background: var(--border-highlight);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.step-num.gold {
  background: var(--primary-gold);
  color: #000;
}

h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
}

.card-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Tabs */
.tab-buttons {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1rem;
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.6rem 0.5rem;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn.active {
  color: var(--accent-cyan);
  border-bottom-color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.05);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* SIWYS QR */
.qr-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 280px;
  background: #ffffff;
  border-radius: 12px;
  padding: 1rem;
  position: relative;
  overflow: hidden;
  margin-bottom: 1rem;
}

.qr-image {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
}

.qr-loading {
  color: #000;
  font-weight: 600;
}

.qr-instructions {
  text-align: center;
}

.qr-instructions p {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.polling-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--accent-cyan);
  margin-bottom: 0.75rem;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background: var(--accent-cyan);
  border-radius: 50%;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.6; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.6; }
}

/* Auth Success Box */
.auth-success-box {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid var(--accent-green);
  border-radius: 8px;
  padding: 1.25rem;
}

.success-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  color: var(--accent-green);
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
}

.badge-icon {
  background: var(--accent-green);
  color: #000;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
}

.player-info label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.did-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #090d16;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.5rem;
  margin: 0.35rem 0 1rem 0;
  word-break: break-all;
}

.did-box code {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: #38bdf8;
}

/* Quick presets */
.quick-preset-dids {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 0.5rem 0 1rem 0;
}

.preset-chip {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  color: #cbd5e1;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: pointer;
  font-family: var(--font-mono);
}

.preset-chip:hover {
  background: rgba(56, 189, 248, 0.2);
  color: #fff;
  border-color: var(--accent-cyan);
}

/* Certificate Card */
.certificate-card {
  border-color: var(--primary-gold);
  background: linear-gradient(180deg, #1a2236 0%, #121827 100%);
  animation: fadeIn 0.4s ease-out;
}

.certificate-seal {
  text-align: center;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1rem;
}

.seal-icon {
  font-size: 2.5rem;
  margin-bottom: 0.25rem;
}

.certificate-seal h3 {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  color: var(--primary-gold);
}

.cert-subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.cert-details {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  font-size: 0.8rem;
}

.cert-row {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.cert-row .label {
  color: var(--text-muted);
}

.cert-row code {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  background: #090d16;
  padding: 0.4rem;
  border-radius: 4px;
  word-break: break-all;
  color: #93c5fd;
}

.attest-qr-box {
  background: #090d16;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1.25rem;
}

.attest-qr-box .qr-container {
  min-height: auto;
  padding: 0.5rem;
  margin-bottom: 0.75rem;
}

.attest-qr-box .qr-image {
  max-width: 220px;
}

.json-details summary {
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-bottom: 0.5rem;
}

.json-details pre {
  background: #090d16;
  padding: 0.75rem;
  border-radius: 6px;
  font-size: 0.7rem;
  overflow-x: auto;
  max-height: 250px;
  color: #cbd5e1;
}

/* History Card */
.history-card h3 {
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.attestations-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 300px;
  overflow-y: auto;
}

.attestation-item {
  background: var(--bg-section);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.6rem;
  font-size: 0.8rem;
}

.attestation-item .item-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.25rem;
}

.attestation-item .char-name {
  font-weight: 600;
  color: var(--primary-gold);
}

.attestation-item .item-did {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Mode Toggle & Update Section */
.character-mode-toggle {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  background: var(--bg-section);
  padding: 0.35rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.mode-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.6rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.mode-btn.active {
  background: var(--border-highlight);
  color: #fff;
}

.update-mode-section {
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid var(--border-highlight);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1.25rem;
  animation: fadeIn 0.3s ease-out;
}

/* Form Styles */
.sheet-header {
  justify-content: space-between;
}

.preset-dropdown {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.form-section {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  background: var(--bg-section);
}

legend {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent-cyan);
  padding: 0 0.5rem;
}

.form-grid {
  display: grid;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #cbd5e1;
}

input[type="text"],
input[type="number"],
select,
textarea {
  background: #090d16;
  border: 1px solid var(--border-color);
  color: #fff;
  border-radius: 6px;
  padding: 0.55rem 0.75rem;
  font-family: var(--font-body);
  font-size: 0.85rem;
  transition: border-color 0.2s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent-cyan);
}

/* Ability Scores Grid */
.abilities-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.75rem;
}

@media (max-width: 768px) {
  .abilities-grid { grid-template-columns: repeat(3, 1fr); }
}

.ability-card {
  background: #090d16;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.75rem 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.ability-name {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--primary-gold);
}

.ability-card input {
  width: 55px;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
  padding: 0.3rem;
}

.ability-mod {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-cyan);
}

/* Saving Throws & Skills */
.saving-throws-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 0.75rem;
  font-size: 0.8rem;
}

.saving-throws-row label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
}

.skills-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.skills-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.skills-toggle-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  cursor: pointer;
}

.skills-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
}

@media (max-width: 900px) {
  .skills-grid { grid-template-columns: repeat(2, 1fr); }
}

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

.skill-card {
  background: #090d16;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.5rem 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  transition: border-color 0.2s, background 0.2s;
}

.skill-card.proficient {
  border-color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.05);
}

.skill-card.expertise {
  border-color: var(--primary-gold);
  background: rgba(245, 158, 11, 0.07);
}

.skill-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.skill-name {
  font-weight: 600;
  font-size: 0.8rem;
  color: #f1f5f9;
}

.skill-stat-pill {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  background: rgba(255, 255, 255, 0.08);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.skill-card-bottom {
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

.skill-prof-select {
  flex: 1;
  padding: 0.25rem 0.4rem !important;
  font-size: 0.75rem !important;
  height: 28px;
}

.skill-pts-box {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.skill-pts-label {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.skill-pts-input {
  width: 48px !important;
  text-align: center;
  font-weight: 700;
  padding: 0.2rem !important;
  height: 28px;
  font-family: var(--font-mono);
  font-size: 0.8rem !important;
}

/* Multiclass Builder */
.classes-builder-section {
  background: #090d16;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.85rem;
  margin: 0.75rem 0;
}

.classes-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.65rem;
}

.total-level-pill {
  background: rgba(59, 130, 246, 0.2);
  border: 1px solid var(--border-highlight);
  color: var(--accent-cyan);
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-size: 0.8rem;
}

.classes-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.class-entry-row {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  background: var(--bg-section);
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

.class-entry-row .class-select-group {
  flex: 1.2;
}

.class-entry-row .class-subclass-group {
  flex: 1.5;
}

.class-entry-row .class-level-group {
  flex: 0.8;
  max-width: 85px;
}

.btn-remove-class {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid var(--accent-red);
  color: #fca5a5;
  border-radius: 6px;
  padding: 0.45rem 0.65rem;
  cursor: pointer;
  height: 35px;
  font-weight: 700;
  transition: all 0.2s;
}

.btn-remove-class:hover {
  background: rgba(239, 68, 68, 0.3);
  color: #fff;
}

.add-class-btn {
  font-size: 0.8rem;
  padding: 0.35rem 0.75rem;
  width: auto !important;
}

/* Action Bar */
.action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
  flex-wrap: wrap;
  gap: 1rem;
}

.submission-target {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.submission-target strong {
  display: block;
  color: var(--accent-cyan);
  font-family: var(--font-mono);
  font-size: 0.8rem;
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-attest, .btn-copy {
  cursor: pointer;
  border: none;
  font-family: var(--font-body);
  font-weight: 600;
  border-radius: 6px;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--border-highlight);
  color: #fff;
  padding: 0.65rem 1rem;
  width: 100%;
}

.btn-primary:hover {
  background: #2563eb;
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 0.4rem 0.75rem;
  font-size: 0.75rem;
  width: 100%;
}

.btn-secondary:hover {
  color: #fff;
  border-color: #64748b;
}

.btn-attest {
  background: linear-gradient(135deg, var(--primary-gold-dark) 0%, var(--primary-gold) 100%);
  color: #000;
  font-size: 1rem;
  font-weight: 700;
  padding: 0.85rem 1.75rem;
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3);
}

.btn-attest:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4);
}

.btn-attest:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-copy {
  background: rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

.btn-copy:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.btn-text {
  background: transparent;
  border: none;
  color: var(--accent-cyan);
  font-size: 0.75rem;
  cursor: pointer;
  text-decoration: underline;
}

.copyable-input {
  display: flex;
  gap: 0.5rem;
}

.copyable-input input {
  flex: 1;
}

.error-msg {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid var(--accent-red);
  color: #fca5a5;
  padding: 0.75rem;
  border-radius: 6px;
  margin-top: 1rem;
  font-size: 0.85rem;
}

.empty-state {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-style: italic;
  text-align: center;
  padding: 1rem;
}

.hidden {
  display: none !important;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
