/* Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.animate-fade-in { animation: fadeIn 0.8s ease-out; }
.animate-slide-up { animation: slideUp 0.6s ease-out; }

/* Transitions */
* { transition: background-color 0.2s, border-color 0.2s, color 0.2s; box-sizing: border-box; }
.button, .app-card, a { transition: all 0.2s ease; }
:root {
  color-scheme: light dark;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --secondary: #10b981;
  --accent: #f59e0b;
  --bg: #ffffff;
  --fg: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --bg-soft: #f9fafb;
  --card-bg: #ffffff;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --radius: 12px;
  --radius-sm: 8px;
  --space: 1rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary: #818cf8;
    --primary-hover: #6366f1;
    --secondary: #34d399;
    --bg: #0f172a;
    --fg: #f1f5f9;
    --muted: #94a3b8;
    --border: #1e293b;
    --bg-soft: #1e293b;
    --card-bg: #1e293b;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
  }
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: 'Pretendard Variable', Pretendard, system-ui, -apple-system, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.site-header {
  padding: 3rem 1rem;
  background: linear-gradient(135deg, var(--primary), #8b5cf6, #ec4899);
  color: white;
  margin-bottom: 3rem;
  box-shadow: var(--shadow);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.site-header::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 80%);
  pointer-events: none;
}

.site-header h1 {
  margin: 0 0 0.5rem 0;
  font-size: 3rem;
  font-weight: 900;
  letter-spacing: -0.05em;
  text-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.site-header p {
  margin: 0;
  font-size: 1.25rem;
  opacity: 0.9;
  font-weight: 500;
}

.site-footer {
  padding: 2rem 1rem;
  text-align: center;
  border-top: 1px solid var(--border);
  margin-top: 4rem;
  color: var(--muted);
  font-size: 0.875rem;
}

.container, .app-container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 1rem;
}

.app-card-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  list-style: none;
  padding: 0;
  margin: 2rem 0;
}

@media (max-width: 576px) {
  .app-card-list {
    grid-template-columns: 1fr;
  }
}

.app-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
}

.app-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}

.app-card h3 {
  margin: 0 0 1rem 0;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--primary);
}

.app-card ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.app-card li {
  margin-bottom: 0.75rem;
}

.app-card a {
  text-decoration: none;
  color: var(--fg);
  font-weight: 500;
  display: block;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  transition: background 0.2s;
}

.app-card a:hover {
  background: color-mix(in srgb, var(--primary) 10%, transparent);
  color: var(--primary);
}

.button {
  appearance: none;
  border: none;
  background: var(--primary);
  color: white;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.button:disabled, .dropdown-item:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.button:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.button.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary-hover);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
  transform: translateY(1px);
}

.dropdown-item.active {
  background: var(--primary);
  color: white;
}

.button.secondary {
  background: var(--bg-soft);
  color: var(--fg);
  border: 1px solid var(--border);
}

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

.panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

input[type="number"], input[type="text"], select, textarea {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: inherit;
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent);
}
.dnd {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: all 0.2s;
  min-height: 240px;
  background: var(--bg-soft);
  gap: 1rem;
}

.dnd.active {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 5%, transparent);
  color: var(--primary);
}
img.preview{max-width:100%;height:auto;display:block}
/* Hide broken img placeholder before src is set */
img.preview:not([src]), img.preview[src=""]{display:none}
small.hint{color:var(--muted)}
.list{list-style:none;margin:0;padding:0;display:grid;gap:10px}
.item{border:1px solid var(--border);border-radius:var(--radius-sm);padding:10px;display:flex;gap:10px;align-items:center}
.item .thumb{width:56px;height:56px;object-fit:cover;border-radius:8px;border:1px solid var(--border);display:block;background:var(--bg-soft)}
.item .meta{font-size:.9rem;color:var(--muted)}
.badge{display:inline-block;padding:2px 8px;border-radius:999px;background:var(--bg-soft);border:1px solid var(--border);font-size:.8rem;color:var(--muted)}
.badge.primary {
  background: color-mix(in srgb, var(--primary) 15%, transparent);
  color: var(--primary);
  border-color: color-mix(in srgb, var(--primary) 30%, transparent);
  font-weight: 600;
}

.badge.success {
  background: color-mix(in srgb, var(--secondary) 15%, transparent);
  color: var(--secondary);
  border-color: color-mix(in srgb, var(--secondary) 30%, transparent);
  font-weight: 600;
}

.badge.error {
  background: #fee2e2;
  color: #ef4444;
  border-color: #fecaca;
  font-weight: 600;
  white-space: nowrap;
}

@media (prefers-color-scheme: dark) {
  .badge.error {
    background: #450a0a;
    color: #fecaca;
    border-color: #7f1d1d;
  }
}
.code{font-family:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; background:var(--bg-soft); border:1px solid var(--border); border-radius:6px; padding:2px 6px; color: var(--fg)}
.form-control.code { padding: 0.75rem; line-height: 1.5; }

/* Shared layouts */
.grid-2{display:grid;grid-template-columns:1fr 1fr;gap:12px}
.grid-3{display:grid;grid-template-columns:repeat(3,1fr);gap:12px}
.toolbar{display:flex;flex-wrap:wrap;gap:8px;margin:8px 0;align-items:center}

/* Diff viewer */
.diff{display:grid;grid-template-columns:1fr 1fr;gap:.5rem}
.diff pre{white-space:pre-wrap;word-break:break-word;background:#fafafa;border:1px solid #eee;padding:.5rem;min-height:220px}
@media (prefers-color-scheme: dark){
  .diff pre{background:#0f1218;border-color:#2a2f3a}
}
.line-add{background:#e6ffed}
.line-del{background:#ffeef0}
.line-mod{background:#fff5b1}

/* Page-specific helpers moved from inline */
.preview-box {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  overflow: auto;
  max-height: 400px;
  min-height: 60px;
  white-space: pre-wrap;
  word-break: break-word;
}
.kv{display:grid;grid-template-columns:140px 1fr;gap:8px;align-items:center}
.claims{display:grid;grid-template-columns:1fr 1fr;gap:6px}

/* Utilities */
.mt-xs{margin-top:6px}
.mt-sm{margin-top:12px}

.file-input-wrapper {
  margin: 1rem 0;
}
.w-100 { width: 100%; }

/* Professional polish */
h1,h2,h3{line-height:1.2;margin:8px 0 10px}
a{color:inherit}
a:hover{opacity:.9}
button:hover, .button:hover{filter:brightness(1.02)}
button.secondary, .button.secondary{border-color:var(--border)}
.header-actions{display:flex;gap:8px;align-items:center;justify-content:space-between}

/* Progress bar */
.progress {
  width: 100%;
  height: 8px;
  background: var(--bg-soft);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #8b5cf6);
  transition: width 0.3s ease;
}

/* Item states */
.item.error{border-color:#7a202c;background:rgba(122,32,44,.06)}
.item .status{font-size:.8rem}
.item-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.button.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  min-width: 60px;
}

/* Responsive */
@media (max-width: 768px){
  .grid-2{grid-template-columns:1fr}
  .grid-3{grid-template-columns:1fr}
  .dnd{min-height:160px}
}
