:root {
  --color-bg: #0f172a;
  --color-bg-gradient: #1e293b;
  --color-surface: #1e293b;
  --color-surface-2: #334155;
  --color-text: #f8fafc;
  --color-muted: #cbd5e1;
  --color-accent: #f97316;
  --color-accent-contrast: #0f172a;
  --color-border: #475569;
  --color-result-bg: rgba(15, 23, 42, 0.6);
  --color-shadow: rgba(0, 0, 0, 0.45);
  --radius: 14px;

  --tag-korean-bg: #ef4444;
  --tag-chinese-bg: #f59e0b;
  --tag-japanese-bg: #ec4899;
  --tag-western-bg: #8b5cf6;
  --tag-street-bg: #10b981;
}

:root[data-theme="light"] {
  --color-bg: #fff7ed;
  --color-bg-gradient: #ffffff;
  --color-surface: #ffffff;
  --color-surface-2: #fef3c7;
  --color-text: #0f172a;
  --color-muted: #64748b;
  --color-accent: #ea580c;
  --color-accent-contrast: #ffffff;
  --color-border: #fed7aa;
  --color-result-bg: #fffbeb;
  --color-shadow: rgba(15, 23, 42, 0.12);
}

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

body {
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo",
    "Noto Sans KR", sans-serif;
  background: radial-gradient(circle at top, var(--color-bg-gradient) 0%, var(--color-bg) 60%);
  color: var(--color-text);
  display: flex;
  justify-content: center;
  padding: 32px 16px 64px;
  transition: background 0.3s ease, color 0.3s ease;
}

.container {
  background: var(--color-surface);
  padding: 36px 32px;
  border-radius: var(--radius);
  box-shadow: 0 24px 60px var(--color-shadow);
  width: 100%;
  max-width: 640px;
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.header {
  text-align: center;
  margin-bottom: 28px;
  position: relative;
}

.header-actions {
  position: absolute;
  top: -4px;
  right: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-btn {
  width: 40px;
  height: 40px;
  min-width: 40px;
  flex: 0 0 auto;
  padding: 0;
  border-radius: 50%;
  background: var(--color-surface-2);
  color: var(--color-text);
  font-size: 18px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--color-border);
}

.header-btn__label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.theme-toggle:hover {
  transform: translateY(-1px) rotate(15deg);
  opacity: 1;
}

#lang-toggle:hover {
  transform: translateY(-1px);
  opacity: 1;
}

:root[data-theme="light"] .theme-toggle__icon::before {
  content: "🌙";
}

:root:not([data-theme="light"]) .theme-toggle__icon::before {
  content: "☀️";
}

h1 {
  font-size: 26px;
  margin-bottom: 8px;
  color: var(--color-accent);
}

.subtitle {
  font-size: 14px;
  color: var(--color-muted);
}

.result-area {
  background: var(--color-result-bg);
  border-radius: 12px;
  padding: 32px 16px;
  margin-bottom: 24px;
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s ease;
}

.menu-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}

.menu-card__media {
  width: 180px;
  height: 180px;
  border-radius: 16px;
  background: var(--color-surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: 0 8px 20px var(--color-shadow);
}

.menu-card__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.menu-card__emoji {
  font-size: 64px;
  line-height: 1;
}

.is-hidden {
  display: none !important;
}

.menu-card__name {
  font-size: 28px;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.5px;
}

.menu-card__category {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  padding: 4px 12px;
  border-radius: 999px;
  min-height: 22px;
}

.menu-card__category:empty {
  display: none;
}

.menu-card--placeholder .menu-card__emoji {
  opacity: 0.5;
  filter: grayscale(0.3);
}

.menu-card--placeholder .menu-card__name {
  color: var(--color-muted);
  font-size: 18px;
  font-weight: 500;
}

.menu-card--pop {
  animation: pop 0.4s ease;
}

.tag--korean { background: var(--tag-korean-bg); }
.tag--chinese { background: var(--tag-chinese-bg); }
.tag--japanese { background: var(--tag-japanese-bg); }
.tag--western { background: var(--tag-western-bg); }
.tag--street { background: var(--tag-street-bg); }

.controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}

.count-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--color-muted);
}

.count-selector select {
  background: var(--color-surface-2);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  cursor: pointer;
}

button {
  background: var(--color-accent);
  color: var(--color-accent-contrast);
  border: none;
  padding: 11px 22px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.3s ease, color 0.3s ease;
  flex: 1;
  min-width: 120px;
}

button:hover {
  transform: translateY(-1px);
  opacity: 0.92;
}

button:active {
  transform: translateY(0);
}

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

.btn-secondary {
  background: var(--color-surface-2);
  color: var(--color-muted);
  flex: 0 0 auto;
  min-width: 90px;
}

.history-title {
  font-size: 15px;
  color: var(--color-muted);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--color-surface-2);
}

.history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--color-result-bg);
  border-radius: 8px;
}

.history-index {
  font-size: 13px;
  color: var(--color-muted);
  min-width: 32px;
  font-weight: 600;
}

.history-thumb {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--color-surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.history-thumb__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.history-emoji {
  font-size: 22px;
  line-height: 1;
}

.history-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
  flex: 1;
}

.history-tag {
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  padding: 3px 10px;
  border-radius: 999px;
}

.history-empty {
  color: var(--color-muted);
  font-size: 14px;
  text-align: center;
  padding: 12px 0;
}

.contact {
  margin-top: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--color-surface-2);
}

.contact-title {
  font-size: 18px;
  color: var(--color-text);
  margin-bottom: 4px;
}

.contact-subtitle {
  font-size: 13px;
  color: var(--color-muted);
  margin-bottom: 18px;
}

.contact-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-row label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-muted);
}

.form-row input,
.form-row textarea {
  background: var(--color-surface-2);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  width: 100%;
  transition: border-color 0.15s ease, background 0.3s ease, color 0.3s ease;
}

.form-row textarea {
  resize: vertical;
  min-height: 96px;
}

.form-row input:focus,
.form-row textarea:focus {
  outline: none;
  border-color: var(--color-accent);
}

.form-honeypot {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

#contact-submit {
  align-self: flex-start;
  min-width: 160px;
  flex: 0 0 auto;
}

.form-feedback {
  font-size: 13px;
  min-height: 18px;
  margin-top: 4px;
}

.form-feedback--success {
  color: var(--tag-street-bg);
}

.form-feedback--error {
  color: var(--tag-korean-bg);
}

@keyframes pop {
  0% { transform: scale(0.6); opacity: 0; }
  60% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); }
}

@media (max-width: 480px) {
  .container { padding: 24px 18px; }
  .menu-card__media { width: 160px; height: 160px; }
  .menu-card__emoji { font-size: 56px; }
  .menu-card__name { font-size: 24px; }
  button { width: 100%; flex: 1 1 100%; }
  .btn-secondary { flex: 1 1 100%; }
  .header-btn { width: 36px; height: 36px; min-width: 36px; }
}
