*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --bg: #0f0f12;
  --surface: #18181c;
  --text: #e4e4e7;
  --muted: #71717a;
  --accent: #a78bfa;
  --accent-hover: #c4b5fd;
  --border: #27272a;
}

[data-theme="light"] {
  --bg: #fafafa;
  --surface: #ffffff;
  --text: #18181b;
  --muted: #52525b;
  --accent: #7c3aed;
  --accent-hover: #5b21b6;
  --border: #e4e4e7;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "DM Sans", system-ui, -apple-system, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}

.header {
  padding: 2rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.header h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.header-logo {
  color: inherit;
  text-decoration: none;
}
.header-logo:hover {
  text-decoration: underline;
}

.header-actions {
  margin: 0.5rem 0 0;
  font-size: 0.9rem;
}

.tagline {
  margin: 0.25rem 0 0;
  font-size: 0.95rem;
  color: var(--muted);
}

.wip {
  font-size: 0.85em;
  opacity: 0.9;
}

.main {
  max-width: 42rem;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.intro {
  margin: 0 0 2rem;
  color: var(--muted);
}

.section {
  margin-bottom: 2.5rem;
}

.section h2 {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
}

.section > p {
  margin: 0 0 1rem;
  color: var(--muted);
}

.actions {
  list-style: none;
  margin: 0;
  padding: 0;
}

.actions li {
  margin-bottom: 0.75rem;
}

.action-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.action-link:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.hint {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.breadcrumb {
  margin: 0 0 1.5rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.form-label {
  display: block;
  margin-bottom: 0.375rem;
  font-weight: 500;
  color: var(--text);
}

.form-input {
  display: block;
  width: 100%;
  max-width: 36rem;
  margin-bottom: 0.25rem;
  padding: 0.5rem 0.75rem;
  font: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.375rem;
}

.form-input::placeholder {
  color: var(--muted);
}

.form-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.form-input + .form-button {
  margin-top: 1rem;
}

.form-hint {
  margin: 0 0 1rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.form-button {
  padding: 0.5rem 1rem;
  font: inherit;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
  background: var(--accent);
  border: none;
  border-radius: 0.375rem;
  cursor: pointer;
}

.form-button:hover:not(:disabled) {
  background: var(--accent-hover);
}

.form-button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.validation-result {
  margin-top: 1.5rem;
}

.validation-result-block {
  display: block;
}

.validation-result-block .name-badge {
  display: inline-block;
}

.validation-result-block .request-doc-button {
  display: block;
  margin-top: 1.25rem;
  width: 100%;
  max-width: 24rem;
}

.request-doc-progress {
  margin-top: 1rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.request-doc-progress ul {
  margin: 0;
  padding-left: 1.25rem;
}

.request-doc-progress li {
  margin: 0.25rem 0 0;
}

.request-doc-progress li:first-child {
  margin-top: 0;
}

.request-doc-progress .step-done {
  color: var(--text);
}

.request-doc-progress .step-skipped {
  font-style: italic;
}

.doc-items {
  list-style: none;
  margin: 0;
  padding: 0;
}

.doc-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.35rem 0 0;
  font-size: 0.875rem;
  color: var(--muted);
}

.doc-item:first-child {
  margin-top: 0;
}

.doc-item-icon {
  flex-shrink: 0;
  width: 1.25rem;
  text-align: center;
  font-size: 1rem;
}

.doc-item--loading .doc-item-icon {
  opacity: 0.8;
}

.doc-item--success .doc-item-icon {
  color: #22c55e;
}

.doc-item--skipped .doc-item-icon {
  color: var(--muted);
}

.doc-item--error .doc-item-icon {
  color: #ef4444;
}

.doc-item-label {
  flex: 1;
}

.doc-item a.action-link {
  margin-left: 0.25rem;
}

@keyframes doc-item-spin {
  to { transform: rotate(360deg); }
}

.doc-item--loading .doc-item-icon::after {
  content: "\u27F3";
  display: inline-block;
  animation: doc-item-spin 0.8s linear infinite;
}

.request-doc-success-heading {
  margin: 0 0 0.5rem;
  font-weight: 600;
  color: var(--text);
}

.request-doc-success {
  margin-top: 1rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.request-doc-success p {
  margin: 0.25rem 0 0;
}

.request-doc-success p:first-child {
  margin-top: 0;
}

.name-badge {
  display: inline-block;
  padding: 1.25rem 2rem;
  background: var(--surface);
  border: 3px solid var(--text);
  border-radius: 0.5rem;
  box-shadow: 0 4px 0 var(--border);
  text-align: center;
}

.name-badge-label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.name-badge-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.name-badge-name {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
  word-break: break-word;
}

.name-badge-edit {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
}

.name-badge-edit:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.name-badge-edit:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Edit name dialog */
.edit-name-dialog {
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--bg);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
}

.edit-name-dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

/* Dialogs: light appearance in dark mode (Edit name, Are you sure) */
.dialog--light {
  background: #fafafa;
  border-color: #e4e4e7;
}

.dialog--light .edit-name-dialog-title {
  color: #18181b;
}

.dialog--light .edit-name-dialog-desc {
  color: #52525b;
}

.dialog--light .form-input {
  color: #18181b;
  background: #fff;
  border-color: #e4e4e7;
}

.dialog--light .form-input::placeholder {
  color: #71717a;
}

.dialog--light .form-button {
  color: #fff;
  background: #7c3aed;
}

.dialog--light .form-button:hover:not(:disabled) {
  background: #5b21b6;
}

.dialog--light .form-button--secondary {
  background: #fff;
  border-color: #e4e4e7;
  color: #18181b;
}

.dialog--light .form-button--secondary:hover:not(:disabled) {
  background: #e4e4e7;
}

.edit-name-dialog-title {
  margin: 0 0 0.25rem;
  font-size: 1.25rem;
  font-weight: 600;
}

.edit-name-dialog-desc {
  margin: 0 0 1rem;
  font-size: 0.875rem;
  color: var(--muted);
}

.edit-name-dialog[open] {
  padding: 1.5rem;
  max-width: 24rem;
}

.edit-name-dialog .form-input {
  margin-bottom: 1rem;
}

.edit-name-dialog-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

.form-button--secondary {
  background: var(--surface);
  border: 1px solid var(--border);
}

.form-button--secondary:hover:not(:disabled) {
  background: var(--border);
}

.validation-error,
.login-error {
  margin-top: 1rem;
  padding: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  color: var(--text);
}

.login-origin-box {
  margin: 1rem 0 1.5rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
}
.login-origin-heading {
  margin: 0 0 0.5rem;
  font-weight: 600;
  font-size: 0.95rem;
}
.login-origin-hint {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.5;
}
.login-origin-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.5rem 0;
  flex-wrap: wrap;
}
.login-origin-row .origin-value {
  flex: 1;
  min-width: 0;
  padding: 0.35rem 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.25rem;
  font-size: 0.9em;
  word-break: break-all;
}
.login-origin-note {
  margin: 0.5rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}
.login-origin-hint code,
.login-origin-note code {
  padding: 0.1rem 0.3rem;
  background: var(--bg);
  border-radius: 0.2rem;
  font-size: 0.9em;
}

.footer {
  padding: 1.5rem;
  border-top: 1px solid var(--border);
  text-align: center;
}

.footer p {
  margin: 0;
  font-size: 0.875rem;
  color: var(--muted);
}

/* Token expiry — bottom center */
.token-expiry {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  font-size: 0.875rem;
  color: var(--muted);
}

.token-expiry a {
  color: var(--accent);
  text-decoration: none;
}

.token-expiry a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.token-expiry--soon {
  font-size: 200%;
}

/* Theme toggle — bottom left */
.theme-toggle {
  position: fixed;
  bottom: 1rem;
  left: 1rem;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.theme-toggle:hover {
  background: var(--border);
}

.theme-toggle:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.theme-toggle-icon {
  display: none;
}

/* Dark mode: show sun (click to go light) */
.theme-toggle-sun {
  display: block;
}

[data-theme="light"] .theme-toggle-sun {
  display: none;
}

[data-theme="light"] .theme-toggle-moon {
  display: block;
}
