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

:root {
  --bg: #f5f5f5;
  --bg-surface: #fff;
  --bg-hover: #e8e8e8;
  --text: #1a1a1a;
  --text-secondary: #666;
  --text-tertiary: #999;
  --border: #ccc;
  --border-light: #e0e0e0;
  --border-lighter: #f0f0f0;
  --success: #0a0;
  --error: #c00;
  --accent: #1a1a1a;
  --accent-contrast: #fff;
  --btn-secondary-bg: #e0e0e0;
  --progress-bg: #e0e0e0;
  --progress-fill: #1a1a1a;
  --code-bg: #fff;
  --spinner-border: #e0e0e0;
  --spinner-accent: #1a1a1a;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0d0d;
    --bg-surface: #1a1a1a;
    --bg-hover: #2a2a2a;
    --text: #e8e8e8;
    --text-secondary: #aaa;
    --text-tertiary: #777;
    --border: #444;
    --border-light: #333;
    --border-lighter: #2a2a2a;
    --success: #4c4;
    --error: #f55;
    --accent: #e8e8e8;
    --accent-contrast: #1a1a1a;
    --btn-secondary-bg: #333;
    --progress-bg: #333;
    --progress-fill: #e8e8e8;
    --code-bg: #222;
    --spinner-border: #333;
    --spinner-accent: #e8e8e8;
  }
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

#app {
  max-width: 640px;
  margin: 0 auto;
  padding: 2rem 1rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  text-align: center;
  margin-bottom: 2rem;
}

header h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tagline {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

main {
  flex: 1;
}

.screen {
  display: none;
  animation: fadeIn 0.2s ease;
}

.screen.active {
  display: block;
}

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

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

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--spinner-border);
  border-top-color: var(--spinner-accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 0.4rem;
}

h2 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
  font-weight: 600;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s, transform 0.1s;
  gap: 0.4rem;
}

.btn:hover {
  opacity: 0.9;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

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

.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
}

.btn-secondary {
  background: var(--btn-secondary-bg);
  color: var(--text);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-text {
  background: transparent;
  color: var(--text-secondary);
  padding: 0.6rem 0.5rem;
}

.btn-text:hover {
  color: var(--text);
}

.btn-danger {
  background: var(--error);
  color: #fff;
}

.btn-small {
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
  background: var(--btn-secondary-bg);
  color: var(--text);
}

.choice-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 2rem;
}

.choice-buttons .btn {
  min-width: 140px;
}

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 2rem;
  text-align: center;
  color: var(--text-secondary);
  transition: border-color 0.2s, background 0.2s;
}

.drop-zone.dragover {
  border-color: var(--accent);
  background: var(--bg-hover);
}

.drop-zone p {
  margin-bottom: 0.5rem;
}

.file-buttons {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 1rem;
}

.file-list {
  margin-top: 1rem;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  background: var(--bg-surface);
}

.file-item {
  display: flex;
  align-items: center;
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border-lighter);
}

.file-item:last-child {
  border-bottom: none;
}

.file-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.file-size {
  color: var(--text-secondary);
  white-space: nowrap;
  margin-left: 0.5rem;
}

.btn-remove {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 0.3rem;
  margin-left: 0.3rem;
  border-radius: 3px;
  transition: color 0.15s, background 0.15s;
}

.btn-remove:hover {
  color: var(--error);
  background: var(--border-lighter);
}

.file-count {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.password-row {
  margin-top: 1rem;
}

.password-row label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.3rem;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--bg-surface);
  color: var(--text);
}

input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 20%, transparent);
}

.actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.5rem;
}

.code-display {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  background: var(--code-bg);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  margin: 1rem 0;
}

.code-display span {
  font-family: monospace;
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  flex: 1;
}

.qr-container {
  display: flex;
  justify-content: center;
  margin: 1rem 0;
}

.qr-container canvas {
  border-radius: 8px;
}

.status {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 0.5rem;
}

.error {
  color: var(--error);
  font-size: 0.85rem;
  margin-top: 0.5rem;
  min-height: 1.2em;
}

.progress-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.progress-item {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 0.75rem;
}

.progress-name {
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.4rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.progress-bar {
  height: 6px;
  background: var(--progress-bg);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--progress-fill);
  border-radius: 3px;
  transition: width 0.15s;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.3rem;
}

.history-log {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  max-height: 300px;
  overflow-y: auto;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border-lighter);
  font-size: 0.85rem;
}

.history-item:last-child {
  border-bottom: none;
}

.history-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-right: 0.5rem;
  min-width: 0;
}

.history-size {
  color: var(--text-secondary);
  white-space: nowrap;
  margin-right: 0.5rem;
}

.history-status {
  color: var(--success);
  font-weight: 500;
  white-space: nowrap;
}

.history-status.error {
  color: var(--error);
}

.history-item .btn-small {
  margin-left: 0.5rem;
}

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

.zip-progress {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 0.5rem;
}

.zip-progress .bar {
  height: 4px;
  background: var(--progress-bg);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 0.3rem;
}

.zip-progress .bar-fill {
  height: 100%;
  background: var(--progress-fill);
  border-radius: 2px;
  transition: width 0.1s;
}

footer {
  text-align: center;
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-light);
  font-size: 0.8rem;
  color: var(--text-tertiary);
}

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

  .choice-buttons .btn {
    min-width: unset;
  }

  .code-display span {
    font-size: 1rem;
  }
}