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

:root {
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-primary-light: #eff6ff;
  --color-success: #16a34a;
  --color-success-light: #f0fdf4;
  --color-error: #dc2626;
  --color-error-light: #fef2f2;
  --color-info: #2563eb;
  --color-info-light: #eff6ff;
  --color-bg: #ffffff;
  --color-surface: #f8fafc;
  --color-border: #e2e8f0;
  --color-text: #1e293b;
  --color-text-secondary: #64748b;
  --color-text-muted: #94a3b8;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    'Helvetica Neue', Arial, 'Noto Sans', 'Noto Sans KR', 'Noto Sans JP',
    sans-serif;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1),
    0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --transition: 150ms ease;
}

body {
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--color-border);
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--color-text);
}

.header-logo svg {
  width: 28px;
  height: 28px;
  color: var(--color-primary);
}

.header-logo span {
  font-weight: 700;
  font-size: 1.125rem;
}

.lang-switcher {
  display: flex;
  gap: 4px;
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  padding: 2px;
}

.lang-btn {
  padding: 6px 12px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  transition: all var(--transition);
}

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

.lang-btn.active {
  background: var(--color-bg);
  color: var(--color-primary);
  box-shadow: var(--shadow);
}

/* ── Main ── */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 24px;
}

.container {
  width: 100%;
  max-width: 640px;
}

/* ── Hero ── */
.hero {
  text-align: center;
  margin-bottom: 32px;
}

.hero h1 {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.hero p {
  color: var(--color-text-secondary);
  font-size: 1.0625rem;
}

.privacy-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
  padding: 6px 14px;
  background: var(--color-success-light);
  color: var(--color-success);
  border-radius: 100px;
  font-size: 0.8125rem;
  font-weight: 600;
}

.privacy-badge svg {
  width: 16px;
  height: 16px;
}

/* ── Upload Area ── */
.upload-area {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--color-surface);
}

.upload-area:hover,
.upload-area.drag-over {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

.upload-area svg {
  width: 48px;
  height: 48px;
  color: var(--color-text-muted);
  margin-bottom: 16px;
}

.upload-area.drag-over svg {
  color: var(--color-primary);
}

.upload-area h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.upload-area p {
  color: var(--color-text-secondary);
  font-size: 0.875rem;
}

.upload-area .hint {
  color: var(--color-text-muted);
  font-size: 0.75rem;
  margin-top: 8px;
}

/* ── File Info ── */
.file-info {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  margin-top: 16px;
}

.file-info.visible {
  display: flex;
}

.file-info svg {
  width: 24px;
  height: 24px;
  color: var(--color-primary);
  flex-shrink: 0;
}

.file-info-text {
  flex: 1;
  min-width: 0;
}

.file-info .file-name {
  font-weight: 600;
  font-size: 0.875rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-info .file-size {
  color: var(--color-text-secondary);
  font-size: 0.75rem;
}

.file-info .remove-file {
  padding: 4px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--color-text-muted);
  border-radius: 4px;
  transition: all var(--transition);
  flex-shrink: 0;
}

.file-info .remove-file:hover {
  color: var(--color-error);
  background: var(--color-error-light);
}

/* ── Password Section ── */
.password-section {
  display: none;
  margin-top: 24px;
}

.password-section.visible {
  display: block;
}

.password-section label {
  display: block;
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: 8px;
}

.password-input-group {
  display: flex;
  gap: 8px;
}

.password-input-group input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-family: var(--font-sans);
  outline: none;
  transition: border-color var(--transition);
}

.password-input-group input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* ── Buttons ── */
.btn-primary {
  padding: 12px 24px;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font-sans);
  white-space: nowrap;
}

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

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ── Messages ── */
.error-message {
  display: none;
  padding: 12px 16px;
  background: var(--color-error-light);
  color: var(--color-error);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin-top: 12px;
}

.error-message.visible {
  display: block;
}

.info-message {
  display: none;
  padding: 12px 16px;
  background: var(--color-info-light);
  color: var(--color-info);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin-top: 12px;
}

.info-message.visible {
  display: block;
}

/* ── Success Section ── */
.success-section {
  display: none;
  margin-top: 24px;
  text-align: center;
}

.success-section.visible {
  display: block;
}

.success-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--color-success-light);
  color: var(--color-success);
  border-radius: 100px;
  font-weight: 600;
  margin-bottom: 16px;
}

.success-badge svg {
  width: 20px;
  height: 20px;
}

.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font-sans);
}

.btn-download:hover {
  background: var(--color-primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
}

.btn-download svg {
  width: 20px;
  height: 20px;
}

.success-section .btn-download {
  margin-top: 16px;
}

.filename-group {
  margin-top: 16px;
  text-align: left;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

.filename-group label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
}

.filename-input-wrapper {
  display: flex;
  align-items: center;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color var(--transition);
}

.filename-input-wrapper:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.filename-input {
  flex: 1;
  padding: 10px 12px;
  border: none;
  outline: none;
  font-size: 0.875rem;
  font-family: var(--font-sans);
  min-width: 0;
}

.filename-ext {
  padding: 10px 12px;
  background: var(--color-surface);
  color: var(--color-text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  border-left: 1px solid var(--color-border);
  flex-shrink: 0;
}

.download-note {
  margin-top: 12px;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* ── Preview Section ── */
.preview-section {
  display: none;
  margin-top: 24px;
}

.preview-section.visible {
  display: block;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.preview-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.preview-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.preview-nav button {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition);
  font-size: 1rem;
}

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

.preview-nav button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.preview-nav span {
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  min-width: 80px;
  text-align: center;
}

.preview-canvas-wrapper {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #f1f5f9;
}

.preview-canvas-wrapper canvas {
  display: block;
  width: 100%;
  height: auto;
}

/* ── Reset ── */
.reset-wrapper {
  text-align: center;
}

.btn-reset {
  display: none;
  margin-top: 16px;
  padding: 10px 20px;
  background: transparent;
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font-sans);
}

.btn-reset.visible {
  display: inline-block;
}

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

/* ── Spinner ── */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

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

/* ── Footer ── */
footer {
  border-top: 1px solid var(--color-border);
  padding: 24px;
  text-align: center;
}

footer p {
  color: var(--color-text-secondary);
  font-size: 0.8125rem;
  max-width: 480px;
  margin: 0 auto;
  line-height: 1.6;
}

footer a {
  color: var(--color-primary);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

.footer-links {
  margin-top: 12px;
  display: flex;
  justify-content: center;
  gap: 16px;
}

/* ── Utilities ── */
.hidden {
  display: none !important;
}

/* ── Responsive ── */
@media (max-width: 640px) {
  main {
    padding: 32px 16px;
  }

  .hero h1 {
    font-size: 1.5rem;
  }

  .upload-area {
    padding: 32px 16px;
  }

  .password-input-group {
    flex-direction: column;
  }

  .header {
    padding: 12px 16px;
  }

  .lang-btn {
    padding: 6px 8px;
    font-size: 0.75rem;
  }
}
