:root {
  color-scheme: light dark;
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #16213a;
  --muted: #6b7280;
  --line: #e3e7ef;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --danger: #dc2626;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 12px rgba(16, 24, 40, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1420;
    --card: #1a2030;
    --text: #eef2f8;
    --muted: #9aa4b5;
    --line: #2a3345;
    --accent: #4f83ff;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  font-size: 18px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  padding-bottom: env(safe-area-inset-bottom);
}
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, textarea:focus-visible, input:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 2px; }

.top { padding: 20px 20px 8px; text-align: center; }
.top h1 { margin: 0; font-size: 24px; letter-spacing: .01em; }
.top .sub { margin: 2px 0 0; color: var(--muted); font-size: 12px; line-height: 1.4; }

.app { max-width: 620px; margin: 0 auto; padding: 8px 16px 32px; display: flex; flex-direction: column; gap: 14px; }

.direction { display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 8px; }
.lang-pick { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.lang-pick .caption { font-size: 12px; color: var(--muted); padding-left: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lang-pick select {
  width: 100%; min-height: 48px; font: inherit; font-weight: 700; font-size: 17px; color: inherit;
  background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 0 36px 0 16px;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
  text-overflow: ellipsis; white-space: nowrap; overflow: hidden;
}
.swap { width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--line); background: var(--card); font-size: 22px; box-shadow: var(--shadow); }
.swap:active { transform: rotate(180deg); transition: transform .2s; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.input-card { padding: 12px 14px 8px; }
textarea {
  width: 100%; min-height: 96px; max-height: 40vh; resize: none; border: 0; background: transparent; color: inherit;
  font: inherit; font-size: 20px; line-height: 1.5; padding: 4px 0; outline: none;
}
.input-foot { display: flex; justify-content: space-between; align-items: center; min-height: 32px; }
.count { color: var(--muted); font-size: 13px; }

.primary {
  width: 100%; min-height: 56px; border: 0; border-radius: 14px; background: var(--accent); color: var(--accent-text);
  font-size: 20px; font-weight: 700; box-shadow: var(--shadow);
}
.primary:disabled { opacity: .6; cursor: progress; }
.ghost { background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 10px 14px; min-height: 44px; font-size: 16px; }
.ghost.small { min-height: 32px; padding: 4px 10px; font-size: 13px; color: var(--muted); }
.ghost:active { background: color-mix(in srgb, var(--accent) 12%, transparent); }

.error { color: var(--danger); margin: 0; font-size: 15px; text-align: center; }

.result { padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.translation { font-size: 24px; font-weight: 600; line-height: 1.45; white-space: pre-wrap; word-break: keep-all; overflow-wrap: anywhere; user-select: text; }
.pron { font-size: 18px; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; min-height: 1.5em; }
.pron.pending::after { content: "···"; letter-spacing: .2em; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .3; } }
.actions { display: flex; gap: 10px; margin-top: 8px; flex-wrap: wrap; }

.history-head { display: flex; justify-content: space-between; align-items: center; padding: 0 4px; }
.history-list { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.history-list li { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; cursor: pointer; }
.history-list li:active { background: color-mix(in srgb, var(--accent) 10%, var(--card)); }
.history-list .src { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-list .dst { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

dialog { border: 0; border-radius: var(--radius); padding: 24px 22px; width: min(92vw, 380px); background: var(--card); color: var(--text); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog h2 { margin: 0 0 8px; font-size: 20px; }
dialog p { margin: 0 0 14px; color: var(--muted); font-size: 15px; }
dialog input { width: 100%; font: inherit; font-size: 22px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: inherit; margin-bottom: 12px; text-align: center; letter-spacing: .1em; }
dialog .error { text-align: left; margin-bottom: 10px; }

[hidden] { display: none !important; }
