/* ==========================================================================
   CSS 초기화 및 전역 변수
   ========================================================================== */
:root {
  --bg-color: #0f172a;
  --card-bg: #1e293b;
  --card-border: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-light: rgba(59, 130, 246, 0.15);
  --secondary: #64748b;
  --secondary-hover: #475569;
  --accent: #10b981;
  --accent-hover: #059669;
  --danger: #ef4444;
  --warning: #f59e0b;
  --focus-ring: rgba(59, 130, 246, 0.4);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-color);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 40px 20px;
  line-height: 1.6;
}

.container {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
}

/* ==========================================================================
   상단 바 (Top Bar: 메인 링크 & 언어 선택)
   ========================================================================== */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 9999px;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid var(--card-border);
  transition: all 0.2s ease;
}

.brand-link:hover {
  color: #38bdf8;
  border-color: rgba(56, 189, 248, 0.4);
  background: rgba(56, 189, 248, 0.1);
}

.brand-icon {
  width: 14px;
  height: 14px;
}

.lang-switcher {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid var(--card-border);
  border-radius: 9999px;
  padding: 3px 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.lang-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  padding: 3px 10px;
  border-radius: 9999px;
  transition: all 0.2s ease;
}

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

.lang-btn.active {
  background: var(--primary);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(59, 130, 246, 0.4);
}

.lang-divider {
  color: var(--card-border);
  font-size: 0.75rem;
  user-select: none;
}

/* ==========================================================================
   헤더 영역
   ========================================================================== */
.header {
  text-align: center;
  margin-bottom: 28px;
}

.badge {
  display: inline-block;
  padding: 4px 12px;
  background-color: var(--primary-light);
  color: #60a5fa;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 9999px;
  border: 1px solid rgba(96, 165, 250, 0.3);
  margin-bottom: 12px;
}

.header h1 {
  font-size: 2rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.98rem;
  word-break: keep-all;
}

/* ==========================================================================
   메인 카드 및 섹션 공통
   ========================================================================== */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow);
}

.section {
  margin-bottom: 24px;
}

.section:last-child {
  margin-bottom: 0;
}

.section-label {
  display: block;
  font-size: 0.92rem;
  font-weight: 600;
  color: #cbd5e1;
  margin-bottom: 10px;
}

/* ==========================================================================
   1. 파일 업로드 영역
   ========================================================================== */
.drop-zone {
  position: relative;
  border: 2px dashed var(--card-border);
  border-radius: var(--radius-md);
  padding: 30px 20px;
  text-align: center;
  background-color: rgba(15, 23, 42, 0.4);
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s;
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--primary);
  background-color: var(--primary-light);
}

.file-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.upload-icon {
  width: 36px;
  height: 36px;
  stroke: var(--text-muted);
  margin-bottom: 10px;
  transition: transform 0.2s, stroke 0.2s;
}

.drop-zone:hover .upload-icon {
  stroke: var(--primary);
  transform: translateY(-2px);
}

.drop-text {
  font-size: 0.95rem;
  color: var(--text-main);
  font-weight: 500;
}

.browse-link {
  color: var(--primary);
  text-decoration: underline;
}

.drop-subtext {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.image-meta {
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: var(--radius-sm);
  word-break: break-all;
}

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

/* ==========================================================================
   2. 비밀번호 입력 영역
   ========================================================================== */
.password-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.password-wrapper input {
  width: 100%;
  padding: 12px 44px 12px 14px;
  background: #0f172a;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.98rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.password-wrapper input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.password-wrapper input::placeholder {
  color: #64748b;
}

.toggle-password-btn {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
}

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

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

.hint-wrapper {
  margin-top: 8px;
}

.hint-wrapper input {
  width: 100%;
  padding: 10px 14px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px dashed var(--card-border);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.2s, background-color 0.2s;
}

.hint-wrapper input:focus {
  border-color: #64748b;
  border-style: solid;
  background: #0f172a;
}

.hint-wrapper input::placeholder {
  color: #475569;
}

/* ==========================================================================
   3. 버튼 공통 및 실행 버튼
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s, opacity 0.2s;
  color: #ffffff;
  user-select: none;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

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

.btn svg {
  width: 18px;
  height: 18px;
}

.action-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

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

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

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

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

.status-message {
  margin-top: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
}

.status-message.success {
  background-color: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #34d399;
}

.status-message.error {
  background-color: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
}

/* ==========================================================================
   4. 캔버스 미리보기 영역
   ========================================================================== */
.canvas-container {
  position: relative;
  background-color: #0b1120;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  min-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 12px;
}

.canvas-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #64748b;
  text-align: center;
  gap: 10px;
  padding: 20px;
}

.canvas-placeholder svg {
  width: 48px;
  height: 48px;
}

.canvas-placeholder p {
  font-size: 0.9rem;
}

#mainCanvas {
  max-width: 100%;
  height: auto;
  display: none;
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  image-rendering: pixelated;
}

/* ==========================================================================
   5. 다운로드 버튼 영역
   ========================================================================== */
.download-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.btn-download {
  background-color: #334155;
}

.btn-download:hover:not(:disabled) {
  background-color: #475569;
}

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

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

/* ==========================================================================
   푸터 영역
   ========================================================================== */
.footer {
  margin-top: 24px;
}

.security-info {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(51, 65, 85, 0.6);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.security-info h3 {
  font-size: 0.9rem;
  color: #e2e8f0;
  margin-bottom: 8px;
}

.security-info ul {
  padding-left: 20px;
}

.security-info li {
  margin-bottom: 6px;
}

.security-info li:last-child {
  margin-bottom: 0;
}

.security-info code {
  background: #0f172a;
  padding: 2px 6px;
  border-radius: 4px;
  color: #38bdf8;
  font-size: 0.8rem;
  font-family: monospace;
}

.footer-bottom {
  margin-top: 18px;
  text-align: center;
}

.footer-links {
  font-size: 0.82rem;
  color: var(--text-muted);
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.footer-link {
  color: #94a3b8;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
}

.footer-link:hover {
  color: #38bdf8;
  text-decoration: underline;
}

.footer-sep {
  color: #475569;
  user-select: none;
}

/* ==========================================================================
   반응형 모바일 스타일
   ========================================================================== */
@media (max-width: 600px) {
  body {
    padding: 20px 12px;
  }

  .card {
    padding: 20px 16px;
  }

  .action-buttons,
  .download-buttons {
    grid-template-columns: 1fr;
  }

  .header h1 {
    font-size: 1.6rem;
  }
}
