* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body { font-family: 'Onest', system-ui, sans-serif; }

:root {
  --bg-0: #eef1fb;
  --bg-1: #f7f8fe;
  --blob-1: rgba(124,108,255,0.35);
  --blob-2: rgba(56,189,248,0.30);
  --blob-3: rgba(236,120,190,0.22);
  --surface: rgba(255,255,255,0.72);
  --surface-solid: #ffffff;
  --panel-line: rgba(20,20,50,0.07);
  --text: #171735;
  --muted: #6a6a86;
  --faint: #9a9ab2;
  --accent: #6c5ce7;
  --accent-2: #3aa0ff;
  --accent-grad: linear-gradient(120deg, #7c6cff 0%, #4f8cff 55%, #37c6f0 100%);
  --chip: rgba(20,20,60,0.05);
  --chip-hover: rgba(20,20,60,0.09);
  --shadow: 0 24px 60px -22px rgba(40,30,110,0.30);
  --menu-bg: rgba(255,255,255,0.96);
}
[data-theme="dark"] {
  --bg-0: #07070f;
  --bg-1: #0d0d1a;
  --blob-1: rgba(124,108,255,0.40);
  --blob-2: rgba(56,189,248,0.28);
  --blob-3: rgba(236,120,190,0.24);
  --surface: rgba(22,22,38,0.62);
  --surface-solid: #14141f;
  --panel-line: rgba(255,255,255,0.08);
  --text: #eef0fb;
  --muted: #a2a3bd;
  --faint: #6a6b85;
  --accent: #9d90ff;
  --accent-2: #56b6ff;
  --accent-grad: linear-gradient(120deg, #9a8bff 0%, #62a0ff 55%, #48d6f5 100%);
  --chip: rgba(255,255,255,0.06);
  --chip-hover: rgba(255,255,255,0.11);
  --shadow: 0 30px 70px -24px rgba(0,0,0,0.7);
  --menu-bg: rgba(24,24,40,0.97);
}

@keyframes floatA { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(6%,8%) scale(1.12); } }
@keyframes floatB { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(-8%,-6%) scale(1.15); } }
@keyframes floatC { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(5%,-7%) scale(0.9); } }
@keyframes shimmer { 0% { background-position: -420px 0; } 100% { background-position: 420px 0; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes popIn { from { opacity: 0; transform: translateY(10px) scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

.page {
  position: relative;
  min-height: 100vh;
  width: 100%;
  overflow: hidden;
  background: linear-gradient(160deg, var(--bg-0), var(--bg-1));
  color: var(--text);
  transition: background .5s ease, color .3s ease;
}

.blob { position: absolute; border-radius: 50%; pointer-events: none; }
.blob-1 { top: -14%; left: -8%; width: 46vw; height: 46vw; background: radial-gradient(circle at 30% 30%, var(--blob-1), transparent 62%); filter: blur(52px); animation: floatA 18s ease-in-out infinite; }
.blob-2 { bottom: -18%; right: -10%; width: 50vw; height: 50vw; background: radial-gradient(circle at 60% 40%, var(--blob-2), transparent 62%); filter: blur(56px); animation: floatB 22s ease-in-out infinite; }
.blob-3 { top: 32%; right: 22%; width: 30vw; height: 30vw; background: radial-gradient(circle at 50% 50%, var(--blob-3), transparent 65%); filter: blur(50px); animation: floatC 26s ease-in-out infinite; }

.shell {
  position: relative;
  z-index: 2;
  max-width: 1120px;
  margin: 0 auto;
  padding: clamp(20px,4vw,42px) clamp(16px,4vw,40px) 56px;
  display: flex;
  flex-direction: column;
  gap: clamp(20px,3.4vw,34px);
  min-height: 100vh;
}

/* Header */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { width: 38px; height: 38px; border-radius: 12px; background: var(--accent-grad); display: flex; align-items: center; justify-content: center; box-shadow: 0 8px 22px -8px var(--accent); flex: none; }
.brand-text { line-height: 1.05; }
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: -0.02em; }
.brand-sub { font-size: 11.5px; color: var(--faint); font-weight: 500; letter-spacing: 0.02em; }

.theme-btn { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px; border: 1px solid var(--panel-line); background: var(--surface); color: var(--text); border-radius: 999px; cursor: pointer; font-family: inherit; font-size: 13px; font-weight: 600; backdrop-filter: blur(14px); transition: background .2s; }
.theme-btn:hover { background: var(--chip-hover); }
.theme-icon { display: inline-flex; }

/* Language row */
.lang-row { position: relative; display: flex; align-items: center; justify-content: center; gap: clamp(8px,2vw,20px); flex-wrap: wrap; }
.lang-select { position: relative; flex: 1; min-width: 130px; max-width: 280px; }
.lang-btn { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; height: 46px; padding: 0 16px; border: 1px solid var(--panel-line); background: var(--surface); color: var(--text); border-radius: 14px; cursor: pointer; font-family: inherit; font-weight: 600; font-size: 14.5px; backdrop-filter: blur(14px); box-shadow: var(--shadow); transition: border-color .2s; }
.lang-btn:hover { border-color: var(--accent); }
.lang-btn-label { display: flex; align-items: center; gap: 9px; min-width: 0; }
.lang-code { font-size: 10.5px; font-weight: 800; letter-spacing: 0.06em; color: #fff; background: var(--accent-grad); padding: 3px 6px; border-radius: 6px; flex: none; }
.lang-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chev { color: var(--faint); flex: none; }

.lang-menu { position: absolute; top: 54px; left: 0; right: 0; z-index: 30; max-height: 280px; overflow: auto; padding: 6px; background: var(--menu-bg); border: 1px solid var(--panel-line); border-radius: 14px; box-shadow: var(--shadow); backdrop-filter: blur(20px); animation: popIn .16s ease; }
.lang-option { width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 11px; border: none; background: transparent; color: var(--text); border-radius: 9px; cursor: pointer; font-family: inherit; font-size: 14px; font-weight: 500; text-align: left; }
.lang-option:hover { background: var(--chip-hover); }
.lang-option.active { background: var(--chip); font-weight: 700; }
.lang-option .opt-code { font-size: 10px; font-weight: 800; letter-spacing: 0.05em; color: var(--muted); width: 34px; flex: none; }

.swap-btn { width: 46px; height: 46px; flex: none; border: 1px solid var(--panel-line); background: var(--surface); color: var(--accent); border-radius: 14px; cursor: pointer; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(14px); box-shadow: var(--shadow); transition: transform .35s ease, border-color .2s; }
.swap-btn:hover { border-color: var(--accent); }

/* Temperature */
.temp-card { background: var(--surface); border: 1px solid var(--panel-line); border-radius: 16px; box-shadow: var(--shadow); backdrop-filter: blur(14px); overflow: hidden; }
.temp-head { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 18px; border: none; background: transparent; color: var(--text); cursor: pointer; font-family: inherit; }
.temp-title { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 600; }
.temp-right { display: flex; align-items: center; gap: 10px; }
.temp-value { font-size: 13px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; background: var(--chip); padding: 3px 10px; border-radius: 999px; }
.temp-chev { transition: transform .25s ease; }
.temp-chev.open { transform: rotate(180deg); }
.temp-body { display: flex; flex-direction: column; gap: 9px; padding: 2px 18px 16px; animation: fadeUp .22s ease; }
.temp-body input[type="range"] { width: 100%; height: 6px; accent-color: var(--accent); cursor: pointer; margin: 2px 0; }
.temp-hint { margin: 0; font-size: 12.5px; line-height: 1.45; color: var(--faint); }

/* Panels */
.panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: clamp(14px,2vw,20px); flex: 1; }
.panel { position: relative; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--panel-line); border-radius: 22px; box-shadow: var(--shadow); backdrop-filter: blur(18px); overflow: hidden; min-height: 340px; }
.panel-bar { position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--accent-grad); opacity: 0; transition: opacity .3s; }
.panel-bar.active { opacity: 1; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 15px 20px 4px; }
.panel-title { font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--faint); }
.translating { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; color: var(--accent); }
.spin { animation: spin .9s linear infinite; }

.panel-text { flex: 1; width: 100%; resize: none; border: none; outline: none; background: transparent; color: var(--text); font-family: inherit; font-size: clamp(17px,1.8vw,20px); line-height: 1.5; padding: 6px 20px 18px; caret-color: var(--accent); }

.panel-out { flex: 1; position: relative; padding: 6px 20px 18px; }
.skeleton { display: flex; flex-direction: column; gap: 13px; padding-top: 4px; }
.sk-line { height: 16px; border-radius: 7px; background: linear-gradient(90deg, var(--chip) 25%, var(--chip-hover) 50%, var(--chip) 75%); background-size: 840px 100%; animation: shimmer 1.5s linear infinite; }
.sk-line:nth-child(2) { animation-delay: .12s; }
.sk-line:nth-child(3) { animation-delay: .24s; }
.sk-line:nth-child(4) { animation-delay: .36s; }
.output { font-size: clamp(17px,1.8vw,20px); line-height: 1.5; color: var(--text); white-space: pre-wrap; animation: fadeUp .35s ease; }
.output-empty { font-size: clamp(17px,1.8vw,20px); line-height: 1.5; color: var(--faint); }

.panel-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--panel-line); }
.panel-foot-end { justify-content: flex-end; }
.counter { font-size: 12.5px; font-weight: 600; color: var(--faint); font-variant-numeric: tabular-nums; }
.counter.over { color: #ef4444; }

.ghost-btn { display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border: none; background: transparent; color: var(--muted); border-radius: 9px; cursor: pointer; font-family: inherit; font-size: 13px; font-weight: 600; transition: background .2s; }
.ghost-btn.has-text { background: var(--chip); }
.ghost-btn:hover { background: var(--chip-hover); }

.primary-btn { display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border: none; background: var(--accent-grad); color: #fff; border-radius: 9px; cursor: pointer; font-family: inherit; font-size: 13px; font-weight: 600; box-shadow: 0 8px 20px -10px var(--accent); transition: transform .15s; }
.primary-btn:hover:not(:disabled) { transform: translateY(-1px); }
.primary-btn:disabled { opacity: 0.4; cursor: default; }

/* Toast */
.toast { position: fixed; bottom: 28px; left: 50%; z-index: 60; display: flex; align-items: center; gap: 9px; padding: 12px 18px; background: var(--surface-solid); border: 1px solid var(--panel-line); border-radius: 12px; box-shadow: var(--shadow); font-size: 14px; font-weight: 600; color: var(--text); transform: translateX(-50%); animation: toastIn .25s ease; }
.toast-icon { display: inline-flex; color: var(--accent); }
