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

:root {
  --color-bg: #0f0f13;
  --color-surface: #1a1a24;
  --color-surface-hover: #24243a;
  --color-border: #6b6b8c;
  --color-primary: #f59e0b;
  --color-primary-hover: #d97706;
  --color-text: #e4e4ed;
  --color-text-muted: #b4b4c8;
  --color-danger: #ff6b6b;
  --color-danger-bg: #3d1010;
  --color-success: #22c55e;
  --focus-ring: 0 0 0 3px #1a1a24, 0 0 0 5px #ffffff;
  --radius: 8px;
  --max-width: 640px;
}

html {
  font-size: 100%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.sr-only.skip-link:focus {
  position: fixed;
  top: 0.5rem;
  left: 0.5rem;
  width: auto;
  height: auto;
  padding: 0.75rem 1.25rem;
  margin: 0;
  clip: auto;
  background: var(--color-primary);
  color: #000;
  font-weight: 700;
  z-index: 1000;
  border-radius: var(--radius);
}

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

header nav {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.nav-link {
  color: var(--color-text);
  text-decoration: none;
  font-weight: 600;
}

.nav-link:hover {
  color: var(--color-primary);
}

.nav-link:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: 4px;
}

.logo {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--color-primary);
  text-decoration: none;
  letter-spacing: 0.05em;
}

.logo:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: 4px;
}

main {
  flex: 1;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.5rem;
  width: 100%;
  scroll-margin-top: 1rem;
}

main:focus:not(:focus-visible) {
  outline: none;
}

h1 {
  font-size: 1.75rem;
  margin: 0 0 0.5rem;
}

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

/* --- Drop Zone --- */
.drop-zone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius);
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.drop-zone {
  display: block;
}

.drop-zone:hover,
.drop-zone:focus-within,
.drop-zone.dragover {
  border-color: var(--color-primary);
  background: rgba(245, 158, 11, 0.08);
}

.drop-zone:focus-within {
  outline: none;
  box-shadow: var(--focus-ring);
}

.drop-zone-text {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
}

.drop-zone-indicator {
  display: none;
  margin: 0.25rem 0 0.5rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.drop-zone.dragover {
  border-width: 3px;
  border-style: solid;
}

.drop-zone.dragover .drop-zone-text {
  text-decoration: underline;
}

.drop-zone.dragover .drop-zone-indicator {
  display: block;
}

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

.field-error {
  color: var(--color-danger);
  margin-top: 0.35rem;
}

.hint code {
  background: var(--color-surface);
  color: var(--color-text);
  padding: 0 0.35rem;
  border-radius: 3px;
  font-size: 0.95em;
}

.file-selected {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-top: 1rem;
}

.file-selected p {
  margin: 0;
}

/* --- Form --- */
.options {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin: 1.5rem 0;
}

.options > legend {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 1rem;
  padding: 0 0.35rem;
}

.field-group {
  margin-bottom: 1rem;
}

.field-group:last-child {
  margin-bottom: 0;
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
}

.checkbox-row input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
  margin-top: 0.15rem;
}

.checkbox-row label {
  margin: 0;
}

label {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 0.3rem;
  color: var(--color-text);
}

input[type="number"],
input[type="text"],
input[type="password"],
input[type="date"],
select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  font-size: 1rem;
  line-height: 1.5;
}

input:focus-visible,
select:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-color: var(--color-primary);
}

/* --- Buttons --- */
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  background: var(--color-primary);
  color: #000;
  transition: background 0.15s;
  min-height: 44px;
  min-width: 44px;
}

button:hover:not(:disabled) {
  background: var(--color-primary-hover);
}

button:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

button.secondary:hover:not(:disabled) {
  background: var(--color-surface-hover);
}

#upload-btn {
  width: 100%;
  font-size: 1.1rem;
  padding: 1rem;
}

/* --- Progress --- */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 1rem;
}

.progress-fill {
  height: 100%;
  background: var(--color-primary);
  width: 0;
  transition: width 0.2s;
  border-radius: 999px;
}

#progress-text,
#download-progress-text {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin: 0.5rem 0 0;
}

/* --- Link Box --- */
.link-box {
  display: flex;
  gap: 0.5rem;
  margin: 1.5rem 0;
}

.link-box.stack {
  display: block;
  margin: 1rem 0;
}

.link-box.stack label {
  margin-bottom: 0.4rem;
}

.link-box .row {
  display: flex;
  gap: 0.5rem;
}

.link-box input {
  flex: 1;
  font-family: monospace;
  font-size: 0.85rem;
}

.warning {
  color: #ffd79a;
}

.actions-row {
  margin-top: 1rem;
  display: flex;
  gap: 0.75rem;
}

button.danger {
  background: var(--color-danger-bg);
  color: #ffd6d6;
  border: 1px solid var(--color-danger);
}

button.danger:hover:not(:disabled) {
  background: #571616;
}

/* --- Fuse Details --- */
.fuse-details {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
}

.fuse-details dt {
  font-weight: 600;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.75rem;
}

.fuse-details dt:first-child {
  margin-top: 0;
}

.fuse-details dd {
  margin: 0.15rem 0 0;
}

/* --- Download View --- */
#download-info p {
  margin: 0.25rem 0;
}

#download-error {
  background: rgba(255, 107, 107, 0.12);
  border: 1px solid var(--color-danger);
  color: #ffd6d6;
  padding: 1rem;
  border-radius: var(--radius);
  margin-top: 1rem;
}

#progress-area:empty,
#download-progress:empty,
#download-error:empty,
#download-info:empty,
#form-error:empty {
  display: none;
}

#form-error {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: rgba(255, 107, 107, 0.12);
  border: 1px solid var(--color-danger);
  color: #ffd6d6;
  border-radius: var(--radius);
}

#progress-area.is-idle,
#download-progress.is-idle {
  display: none;
}

#password-prompt {
  margin-top: 1.5rem;
}

#password-prompt label {
  font-weight: 600;
  margin-bottom: 0.5rem;
}

#password-prompt input {
  margin-bottom: 0.75rem;
}

#download-no-password {
  margin-top: 1.5rem;
}

#claim-prompt,
#password-prompt {
  margin-top: 1rem;
}

/* --- Account --- */
.account-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin: 1.5rem 0;
}

.account-panel.danger-panel {
  border-color: var(--color-danger);
}

.panel-heading {
  font-size: 1.1rem;
  margin: 0 0 0.5rem;
}

#new-number {
  font-size: 1.05rem;
  letter-spacing: 0.08em;
}

.fuse-item {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  justify-content: space-between;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin: 0.75rem 0;
}

.fuse-item-name {
  font-weight: 600;
  margin: 0 0 0.35rem;
  word-break: break-word;
}

.fuse-item-meta {
  margin: 0;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.fuse-item button {
  flex-shrink: 0;
}

.fuse-item-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.fuse-empty {
  color: var(--color-text-muted);
}

@media (max-width: 480px) {
  .fuse-item {
    flex-direction: column;
  }

  .fuse-item-actions {
    flex-direction: column;
    width: 100%;
  }

  .fuse-item button {
    width: 100%;
  }
}

/* --- Footer --- */
footer {
  padding: 1.5rem;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--color-border);
}

/* --- Responsive --- */
@media (max-width: 480px) {
  main {
    padding: 1.5rem 1rem;
  }

  .link-box {
    flex-direction: column;
  }

  .link-box button {
    width: 100%;
  }

  .link-box .row,
  .actions-row {
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
