@font-face {
  font-family: 'Digits';
  src: url('fonts/digits.woff2') format('woff2');
  font-weight: 400 700;
  font-display: swap;
}

/* 계산기 — 2026-11-27 v4: 원색 팔레트(파랑·초록·주황·보라·청록) + 가운데 정렬
   색은 이 :root 한 곳에서만 바꾼다. 대비 수치는 work/디자인-업그레이드-기록.md 참조. */
:root {
  /* 바탕 */
  --bg: #eef3fb;
  --surface: #ffffff;
  --surface-2: #e9f0fa;
  --line: #d3e0f1;
  /* 글자 — 본문 16.9:1 · 보조 5.2:1 (흰 바탕 기준) */
  --text: #0d1b2a;
  --text-2: #2b3a4d;
  --muted: #55677e;
  /* 원색 팔레트 — 한 화면에 5색까지만 */
  --blue: #0b5fd0;
  --blue-deep: #0a3f96;
  --blue-soft: #e8f0ff;
  --green: #0a7d52;
  --green-deep: #075f3f;
  --green-soft: #e3f7ee;
  --orange: #b8480c;
  --orange-deep: #8f3607;
  --orange-soft: #fff0e4;
  --purple: #6d28d9;
  --purple-deep: #511fa8;
  --purple-soft: #f2ebff;
  --teal: #0c6f86;
  --teal-deep: #085366;
  --teal-soft: #e2f5fa;
  /* 쓰임새 이름 */
  --accent: var(--green);
  --accent-press: var(--green-deep);
  --accent-soft: var(--green-soft);
  --primary: var(--blue);
  --primary-deep: var(--blue-deep);
  --primary-soft: var(--blue-soft);
  --red: #b8480c;
  --radius-key: 20px;
  --shadow: 0 1px 2px rgba(15, 45, 90, .05), 0 10px 24px rgba(15, 45, 90, .08);
  --deep: #0c2547;
  --deep-2: #123a6b;
  --amber: #ffc247;
  --coral: #b8480c;
  --font-num: 'Digits', ui-rounded, system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  background-image:
    radial-gradient(120% 60% at 6% 0%, #d6e6ff 0%, rgba(214, 230, 255, 0) 60%),
    radial-gradient(110% 52% at 100% 0%, #ffe6f0 0%, rgba(255, 230, 240, 0) 56%),
    radial-gradient(100% 58% at 50% 106%, #d9f2ec 0%, rgba(217, 242, 236, 0) 60%);
  background-attachment: fixed;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    "Liberation Sans", "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans CJK KR",
    "Noto Sans JP", "Noto Sans SC", "Noto Sans Devanagari", "Noto Sans Arabic", "DejaVu Sans",
    Arial, sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}

button, input, select { font-family: inherit; }
button { cursor: pointer; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

.app {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  height: 100dvh;
  background: transparent;
  overflow: hidden;
}
.view {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}
.view[hidden] { display: none; }

/* ---------- 상단 아이콘 줄 ---------- */

/* ---------- 맨 위 얇은 줄: 언어 버튼만 오른쪽 끝 ---------- */
.topstrip {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  height: calc(34px + env(safe-area-inset-top));
  padding: calc(env(safe-area-inset-top)) 8px 0;
}

/* ---------- 맨 위 이름표: 성일 Calculator + 별표 ---------- */
.brandbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 0 8px 0 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: #6c8d80;
  user-select: none;
}
.brandbar__title {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
/* 이름 줄·최상단 줄의 버튼: 같은 폭·같은 오른쪽 여백으로 세로 정렬 */
.icon-btn--brand,
.icon-btn--lang {
  flex: 0 0 auto;
  width: 34px;
  height: 30px;
  border-radius: 10px;
}
.icon-btn--brand svg { width: 19px; height: 19px; }
.brandbar__emoji {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  animation: brand-bob 3.2s ease-in-out infinite;
}
.brandbar__emoji svg { width: 100%; height: 100%; display: block; }
@keyframes brand-bob {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-2px) rotate(-5deg); }
}
@media (prefers-reduced-motion: reduce) {
  .brandbar__emoji { animation: none; }
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  padding: 2px 10px 2px;
  flex: 0 0 auto;
}
.topbar .icon-btn { flex: 0 0 auto; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #10463a;
  transition: background .15s ease, color .15s ease, transform .08s ease;
}
.icon-btn:active { background: rgba(18, 160, 106, .14); transform: scale(.94); }
.icon-btn.is-on { color: var(--accent); background: var(--accent-soft); }

/* ---------- 화면 표시부 ---------- */
.display {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  flex: 1 1 auto;
  min-height: 112px;
  max-height: 31vh;
  margin: 0 12px 10px;
  padding: 12px 18px 16px;
  gap: 6px;
  overflow: hidden;
  border-radius: 26px;
  background: linear-gradient(145deg, #0d332a 0%, #124b3a 48%, #0e6b4d 100%);
  box-shadow: 0 14px 30px rgba(12, 60, 45, .26), inset 0 1px 0 rgba(255, 255, 255, .1);
  position: relative;
}
.display::before {
  content: "";
  position: absolute;
  left: 16px;
  bottom: 14px;
  width: 104px;
  height: 104px;
  opacity: .1;
  background-repeat: no-repeat;
  background-size: contain;
  background-image: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='2.4' y='2' width='19.2' height='20' rx='5.4' fill='%23ffffff'/%3E%3Crect x='6' y='5.4' width='12' height='4' rx='1.8' fill='%230d332a'/%3E%3Ccircle cx='8.5' cy='13.4' r='1.3' fill='%230d332a'/%3E%3Ccircle cx='15.5' cy='13.4' r='1.3' fill='%230d332a'/%3E%3Cpath d='M8.9 16.4c.9 1.1 2 1.6 3.1 1.6s2.2-.5 3.1-1.6' fill='none' stroke='%230d332a' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  pointer-events: none;
}
.display::after {
  content: "";
  position: absolute;
  top: -46%;
  right: -18%;
  width: 62%;
  height: 150%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 194, 71, .22) 0%, rgba(255, 194, 71, 0) 70%);
  pointer-events: none;
}
.display .display-expr { color: rgba(221, 245, 235, .72); }
.display .display-big { color: #ffffff; text-shadow: 0 2px 10px rgba(0, 0, 0, .22); }
.display .display-kr { color: var(--amber); }

.display-head {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-height: 26px;
}
.display-head[hidden] { display: none; }


.display-expr {
  flex: 1 1 auto;
  text-align: right;
  font-family: var(--font-num);
  font-size: 17.5px;
  font-weight: 400;
  line-height: 1.35;
  color: var(--muted);
  white-space: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  font-variant-numeric: tabular-nums;
  min-height: 23px;
}
.display-expr::-webkit-scrollbar { display: none; }

.display-big {
  text-align: right;
  font-family: var(--font-num);
  font-size: 38px;
  font-weight: 500;
  line-height: 1.12;
  letter-spacing: -.6px;
  color: var(--text);
  white-space: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  font-variant-numeric: tabular-nums;
  transition: font-size .12s ease;
  cursor: pointer;
}
.display-big::-webkit-scrollbar { display: none; }

.display-kr {
  text-align: right;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: -.2px;
  white-space: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}
.display-kr::-webkit-scrollbar { display: none; }

/* ---------- 공학용 줄 ---------- */
.sci {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  padding: 2px 10px 8px;
  flex: 0 0 auto;
  animation: sci-in .16s ease-out;
}
.sci[hidden] { display: none; }

@keyframes sci-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.sci-key {
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: #e3eafa;
  color: #34405a;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -.2px;
  display: grid;
  place-items: center;
  transition: background .13s ease, transform .07s ease, color .13s ease;
}
.sci-key:active { transform: scale(.95); background: #d2ddf6; }
.sci-key.is-on { background: var(--accent); color: #fff; }

/* ---------- 기본 키패드 ---------- */
.keypad {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: minmax(0, 1fr);
  align-content: stretch;
  gap: 8px;
  padding: 2px 10px 8px;
  flex: 1 1 auto;
  min-height: 0;
}
.keypad .key { height: 100%; min-height: 0; max-height: 84px; }
.keypad .key-op, .keypad .key-eq { height: 60px; width: 60px; }

.key {
  display: grid;
  place-items: center;
  height: clamp(52px, 7.1vh, 66px);
  padding: 0;
  border: 0;
  border-radius: var(--radius-key);
  background: var(--surface);
  color: var(--text);
  font-size: 19px;
  font-weight: 500;
  line-height: 1;
  box-shadow: var(--shadow);
  user-select: none;
  transition: background .12s ease, transform .07s ease;
}
.key svg { width: 26px; height: 26px; stroke-width: 1.7; }
.keypad .key:not(.key-op):not(.key-eq) {
  font-family: var(--font-num);
  font-weight: 500;
  border: 1px solid #e8f1ec;
  box-shadow: 0 1px 1px rgba(16, 60, 45, .04), 0 8px 18px rgba(16, 60, 45, .06);
}
.keypad .key-red { border-color: #ffe2e7; }
.key-paren { font-size: 18px !important; letter-spacing: .5px; }
.key:active { background: #eceded; transform: scale(.965); }

.key-op {
  width: 64px;
  height: 64px;
  flex: 0 0 auto;
  justify-self: center;
  align-self: center;
  border-radius: 50%;
  background: linear-gradient(158deg, #16755a 0%, #0d4636 62%, #0a3830 100%);
  box-shadow: 0 6px 14px rgba(10, 56, 45, .26), inset 0 1px 0 rgba(255, 255, 255, .18);
  color: #dff8ee;
  font-family: var(--font-num);
  font-weight: 500;
  font-size: 18px;
}
.key-op:active { background: linear-gradient(158deg, #0f6149 0%, #0a3a2d 62%, #08302a 100%); }

.key-red { color: var(--red); }
.key-eq {
  width: 64px;
  height: 64px;
  flex: 0 0 auto;
  justify-self: center;
  align-self: center;
  border-radius: 50%;
  background: linear-gradient(145deg, #ffc247 0%, #ff8a34 52%, #f4593f 100%);
  color: #fff;
  font-family: var(--font-num);
  font-size: 19px;
  box-shadow: 0 8px 20px rgba(244, 89, 63, .38), inset 0 1px 0 rgba(255, 255, 255, .38);
}
.key-eq:active { background: linear-gradient(145deg, #f7b23c 0%, #f47f2c 52%, #dd4f38 100%); transform: scale(.965); }

/* ---------- 단위 계산기 ---------- */
.subhead {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 56px;
  padding: calc(6px + env(safe-area-inset-top)) 10px 6px;
  flex: 0 0 auto;
}
.subhead h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.5px;
}

.unit-cats {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px 12px 12px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
  -webkit-mask-image: linear-gradient(90deg, #000 0, #000 92%, transparent 100%);
  mask-image: linear-gradient(90deg, #000 0, #000 92%, transparent 100%);
}
.unit-cats::-webkit-scrollbar { display: none; }

.cat {
  flex: 0 0 auto;
  padding: 9px 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -.3px;
  transition: background .14s ease, color .14s ease;
}
.cat.is-active { background: var(--surface-2); color: var(--text); font-weight: 700; }
.cat:active { background: #e7e9ed; }

.unit-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 2px 20px 0;
}

.unit-row { padding: 18px 2px 16px; }

.unit-pick {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 4px 2px 2px;
  border-radius: 8px;
  color: var(--text-2);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -.3px;
}
.unit-pick .caret { width: 16px; height: 16px; stroke-width: 2; color: var(--text-2); }
.unit-pick select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  border: 0;
  font-size: 16px;
}

.unit-num {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
  min-height: 46px;
}
.unit-value {
  max-width: 82%;
  font-size: clamp(28px, 8.6vw, 38px);
  font-weight: 500;
  letter-spacing: -.7px;
  color: #4a5058;
  white-space: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.unit-value::-webkit-scrollbar { display: none; }
.unit-suffix { font-size: 16px; color: var(--muted); font-weight: 500; }

.unit-row.is-active .unit-value { color: var(--text); font-weight: 600; }
.unit-row.is-active .unit-num::after {
  content: "";
  width: 2px;
  height: 1.25em;
  margin-left: 1px;
  align-self: center;
  background: var(--accent);
  animation: blink 1.1s steps(1, end) infinite;
}
@keyframes blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }

.unit-div { height: 1px; background: var(--line); }

.unit-keypad {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 10px 22px calc(14px + env(safe-area-inset-bottom));
  justify-items: center;
  flex: 0 0 auto;
}
.u-key {
  display: grid;
  place-items: center;
  width: 100%;
  max-width: 82px;
  aspect-ratio: 1 / 1;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  font-size: 26px;
  font-weight: 500;
  box-shadow: var(--shadow);
  transition: background .12s ease, transform .07s ease;
}
.u-key svg { width: 26px; height: 26px; stroke-width: 1.8; }
.u-key:active { background: #eceded; transform: scale(.94); }
.u-key.u-red { color: var(--red); }
.u-key.u-arrow {
  background: var(--orange);
  color: #fff;
  box-shadow: 0 8px 18px rgba(244, 121, 43, .28);
}
.u-key.u-arrow:active { background: #e06c21; }
.u-key.u-arrow.is-on { box-shadow: 0 0 0 3px rgba(244, 121, 43, .22), 0 8px 18px rgba(244, 121, 43, .28); }

/* ---------- 생활·사업 계산 ---------- */
.life-tabs {
  display: flex;
  gap: 6px;
  padding: 2px 14px 12px;
  flex: 0 0 auto;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.life-tabs::-webkit-scrollbar { display: none; }
.life-tabs .life-tab { flex: 0 0 auto; padding: 10px 15px; white-space: nowrap; }
.life-tab {
  flex: 1 1 0;
  padding: 10px 4px;
  border: 0;
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -.3px;
  box-shadow: 0 1px 2px rgba(17, 24, 39, .04);
  transition: background .14s ease, color .14s ease;
}
.life-tab.is-active { background: #2f3339; color: #fff; box-shadow: none; }
.life-tab:active { transform: scale(.97); }

.life-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 2px 14px calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.card[hidden] { display: none; }

.card {
  background: var(--surface);
  border-radius: 20px;
  padding: 18px 16px 16px;
  box-shadow: var(--shadow);
}
.card h2 {
  margin: 0 0 5px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.3px;
}
.hint {
  margin: 0 0 10px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
  word-break: keep-all;
}
.note {
  margin: 10px 2px 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
  word-break: keep-all;
  overflow-wrap: break-word;
}

.field {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 2px;
  border-bottom: 1px solid var(--line);
}
.card .field:nth-last-of-type(1) { border-bottom: 0; }
.field span:first-child {
  flex: 0 0 78px;
  font-size: 14px;
  color: #4d5560;
  letter-spacing: -.2px;
}
.field input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: transparent;
  text-align: right;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -.4px;
  color: var(--text);
  outline: none;
  font-variant-numeric: tabular-nums;
}
.field input::placeholder { color: #c4c8cf; font-weight: 500; }
.field .won { flex: 0 0 auto; font-size: 13px; color: var(--muted); }

.result-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  padding: 14px 14px;
  border-radius: 14px;
  background: #eaf8f1;
}
.result-main span { font-size: 13.5px; font-weight: 600; color: #5b6472; }
.result-main strong {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -.6px;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.result-main strong.loss { color: var(--red); }

.result-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 8px;
}
.result-grid.one { grid-template-columns: 1fr; }
.result-grid div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f6f7f9;
}
.result-grid span { font-size: 12.5px; color: var(--muted); }
.result-grid b { font-size: 15.5px; font-weight: 700; letter-spacing: -.3px; }

/* ---------- 스마트 계산 ---------- */
/* 5개 탭을 줄 전체에 균등 배분 (넘칠 때만 스크롤) */
.smart-tabs {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 6px;
  padding: 2px 12px 8px;
  overflow-x: visible;
}
.smart-tabs .life-tab {
  flex: 0 0 auto;
  padding: 10px 2px;
  font-size: 13px;
  letter-spacing: -.4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.demo-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 0 14px 10px;
  flex: 0 0 auto;
}
.demo-row::-webkit-scrollbar { display: none; }
.demo-row .chip { flex: 0 0 auto; background: #fff; }

.tts-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin: 0 0 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: #5b6472;
}

.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch i {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #d7dbe2;
  transition: background .16s ease;
}
.switch i::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(17, 24, 39, .18);
  transition: transform .16s ease;
}
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(18px); }

.mem-chip {
  display: block;
  width: 100%;
  margin: 10px 0 0;
  padding: 9px 12px;
  border: 1px dashed #c9d8f3;
  border-radius: 12px;
  background: #f8fbff;
  color: #3b6fc4;
  font-size: 12.5px;
  font-weight: 600;
  text-align: left;
}

.smart-out-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.mini-btn {
  flex: 0 0 auto;
  padding: 4px 9px;
  border: 0;
  border-radius: 999px;
  background: #e3edff;
  color: #2f6fe0;
  font-size: 11.5px;
  font-weight: 700;
}
.mini-btn:active { background: #d5e4ff; }

/* 메모 장부 */
#memo-input {
  width: 100%;
  min-height: 128px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8f9fb;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  resize: vertical;
  outline: none;
}
#memo-input:focus { border-color: var(--accent); background: #fff; }

.memo-list {
  margin-top: 10px;
  max-height: 190px;
  overflow-y: auto;
  border-top: 1px solid var(--line);
}
.memo-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 2px;
  border-bottom: 1px solid #f0f1f4;
  font-size: 13px;
}
.memo-line {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #6b7280;
}
.memo-val { flex: 0 0 auto; font-weight: 700; color: #20242b; }
.memo-val.neg { color: var(--red); }
.memo-val.muted { color: #c0c5cd; font-weight: 500; }

.memo-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #f2f6ff;
}
.memo-total span { font-size: 13.5px; font-weight: 600; color: #5b6472; }
.memo-total strong { font-size: 23px; font-weight: 700; color: var(--accent); letter-spacing: -.5px; }
  .memo-total em { font-style: normal; font-size: 12.5px; font-weight: 600; color: #3f7a63; margin-left: auto; }

.memo-actions { display: flex; gap: 8px; margin-top: 10px; }
.memo-hint {
  margin: 9px 2px 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
  letter-spacing: -0.01em;
}
.ghost-btn {
  flex: 1 1 0;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: #4d5560;
  font-size: 13px;
  font-weight: 600;
}
.ghost-btn:active { background: #f1f3f6; }

.smart-input {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 10px;
}
.smart-input input {
  flex: 1 1 auto;
  min-width: 0;
  height: 48px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8f9fb;
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color .15s ease, background .15s ease;
}
.smart-input input::placeholder { color: #b3b8c1; font-size: 12.5px; }
.smart-input input:focus { border-color: var(--accent); background: #fff; }

.mic-btn {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  transition: background .15s ease, color .15s ease;
}
.mic-btn svg { width: 21px; height: 21px; stroke-width: 1.9; }
.mic-btn:active { background: #dbe8fd; }
.mic-btn.is-rec { background: #ffe8e8; color: var(--red); animation: rec 1.1s ease-out infinite; }
@keyframes rec {
  0% { box-shadow: 0 0 0 0 rgba(229, 72, 77, .35); }
  100% { box-shadow: 0 0 0 12px rgba(229, 72, 77, 0); }
}

.primary-btn {
  width: 100%;
  height: 48px;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -.2px;
  transition: background .13s ease, transform .07s ease;
}
.primary-btn:active { background: var(--accent-press); transform: scale(.99); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip {
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #4d5663;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: -.2px;
}
.chip:active { background: #eef0f4; }

.smart-out {
  margin-top: 14px;
  padding: 14px 14px 12px;
  border-radius: 16px;
  background: #f2f7ff;
  animation: fade-in .18s ease;
}
.smart-out-label { margin: 0; font-size: 12.5px; font-weight: 600; color: #5b6472; }
.smart-out-value {
  margin: 3px 0 0;
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -.6px;
  color: var(--accent);
  word-break: break-all;
}
.smart-out-kr { margin: 2px 0 0; font-size: 13px; font-weight: 600; color: #4b638f; }

.steps {
  list-style: none;
  margin: 12px 0 0;
  padding: 10px 0 0;
  border-top: 1px solid #e0e9fa;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.steps li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  line-height: 1.4;
}
.steps li span { color: #6b7280; flex: 0 0 auto; }
.steps li b { font-weight: 700; color: #20242b; text-align: right; }
.steps li.is-total b { color: var(--accent); }

.seg {
  display: flex;
  gap: 5px;
  padding: 4px;
  margin: 6px 0 8px;
  border-radius: 12px;
  background: #f1f3f7;
}
.seg-btn {
  flex: 1 1 0;
  padding: 9px 6px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #6b7280;
  font-size: 13px;
  font-weight: 600;
}
.seg-btn.is-active { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(17, 24, 39, .09); }

.smart-div { height: 1px; background: var(--line); margin: 20px 0 16px; }
.field-date input { font-size: 15px; font-weight: 600; color: var(--text-2); }


/* ---------- 공학·그래프 ---------- */
.eng-body { padding-top: 2px; }
.eng-calc { display: flex; flex-direction: column; gap: 8px; }
.eng-display {
  padding: 6px 8px 8px;
  text-align: right;
  min-height: 86px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 4px;
}
.eng-display .display-big { font-size: 40px; }
.eng-sci { padding: 0; }
.eng-keypad {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  padding-bottom: 8px;
}
.eng-keypad .key { height: 48px; font-size: 22px; border-radius: 16px; }
.eng-keypad .key svg { width: 22px; height: 22px; }
.eng-keypad .key-eq { font-size: 24px; }

.graph-wrap {
  position: relative;
  height: 260px;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
}
.graph-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.graph-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }
.graph-read { font-size: 12px; color: #5b6472; font-variant-numeric: tabular-nums; }
.graph-btns { display: flex; gap: 4px; flex: 0 0 auto; }
.graph-btns button {
  min-width: 34px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: #4d5560;
  font-size: 13px;
  font-weight: 600;
}
.graph-btns button:active { background: #f1f3f6; }
.graph-draw { align-self: stretch; padding: 0 13px; border-radius: 12px; height: 48px; }

.coef-row { display: flex; gap: 8px; margin: 6px 0 10px; }
.coef {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8f9fb;
}
.coef span { font-size: 12px; font-weight: 700; color: #8b9099; }
.coef input {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  text-align: right;
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  outline: none;
}
.eq-out {
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #f2f6ff;
  color: var(--accent);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -.4px;
  word-break: break-all;
}
.eq-out.small { font-size: 14.5px; color: #2f6fe0; }
.lin-row { display: flex; align-items: center; gap: 6px; margin: 6px 0; font-size: 12.5px; color: #6b7280; }
.lin-row input {
  flex: 1 1 0;
  width: 100%;
  min-width: 0;
  padding: 9px 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8f9fb;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  outline: none;
}
.lin-row input:focus { border-color: var(--accent); background: #fff; }

/* ---------- 계산 기록 ---------- */
.sheet { position: absolute; inset: 0; z-index: 60; }
.sheet[hidden] { display: none; }
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, .3);
  backdrop-filter: blur(1.5px);
  animation: fade-in .16s ease;
}
.sheet-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(330px, 84%);
  height: 100%;
  background: var(--surface);
  border-radius: 0 24px 24px 0;
  box-shadow: 18px 0 44px rgba(15, 23, 42, .16);
  animation: slide-in .18s ease-out;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-in { from { transform: translateX(-14px); opacity: .6; } to { transform: translateX(0); opacity: 1; } }

.sheet-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(14px + env(safe-area-inset-top)) 10px 8px 18px;
}
.sheet-panel h2 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -.3px; }

.sheet-list { flex: 1 1 auto; overflow-y: auto; padding: 2px 10px 8px; }

.hist-item {
  display: block;
  width: 100%;
  padding: 11px 10px 10px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  text-align: right;
  transition: background .13s ease;
}
.hist-item:active { background: #f3f4f6; }
.hist-memo {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #2f6fe0;
  font-size: 11.5px;
  font-weight: 700;
}
.hist-expr {
  display: block;
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hist-res {
  display: block;
  margin-top: 2px;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}
.hist-foot {
  display: flex;
  justify-content: flex-end;
  margin-top: 2px;
}
.memo-btn {
  padding: 4px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #9aa0a9;
  font-size: 11.5px;
  font-weight: 600;
}
.memo-btn:active { background: #f0f1f4; }
.memo-input {
  width: 100%;
  margin-top: 4px;
  padding: 7px 9px;
  border: 1px solid #cfd6e4;
  border-radius: 9px;
  background: #fff;
  font-size: 12.5px;
  text-align: right;
  outline: none;
}
.memo-input:focus { border-color: var(--accent); }

.hist-empty {
  padding: 48px 18px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.7;
  word-break: keep-all;
}

.sheet-panel footer {
  padding: 10px 14px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}
#history-clear {
  width: 100%;
  padding: 13px;
  border: 0;
  border-radius: 14px;
  background: #f3f4f6;
  color: #4d5560;
  font-size: 14.5px;
  font-weight: 600;
}
#history-clear:active { background: #e8eaee; }

/* ---------- 알림 ---------- */
.toast {
  position: absolute;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translate(-50%, 6px);
  z-index: 80;
  max-width: 80%;
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(20, 23, 28, .9);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 넓은 화면 ---------- */
@media (min-width: 720px) {
  body {
    display: grid;
    place-items: center;
    min-height: 100dvh;
    background:
      radial-gradient(900px 520px at 50% -8%, #ffffff 0%, #eef1f6 58%, #e6eaf1 100%);
  }
  .app {
    height: min(880px, calc(100dvh - 40px));
    border-radius: 34px;
    border: 1px solid rgba(15, 23, 42, .06);
    box-shadow: 0 26px 70px rgba(15, 23, 42, .14);
  }
  .key { height: 62px; }
}

@media (max-height: 720px) {
  .key { height: 50px; font-size: 24px; }
  .sci-key { height: 36px; font-size: 13px; }
  .display { min-height: 76px; }
  .display-big { font-size: 38px; }
  .eng-display { min-height: 62px; }
  .eng-keypad .key { height: 44px; font-size: 20px; }
  .eng-sci .sci-key { height: 34px; font-size: 12.5px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001s !important; transition-duration: .001s !important; }
}

/* ---------- 가로·낮은 화면(폴드 펼침, 가로 회전) ---------- */
@media (orientation: landscape) and (max-height: 560px) {
  .brandbar { display: none; }
  .topbar { min-height: 40px; padding-top: calc(2px + env(safe-area-inset-top)); }
  .icon-btn { width: 40px; height: 40px; }
  #view-calc { flex-direction: row; align-items: stretch; }
  #view-calc .display {
    flex: 1 1 auto;
    min-width: 0;
    max-height: none;
    min-height: 0;
    margin: 4px 0 6px 10px;
    padding: 10px 14px 12px;
  }
  #view-calc .display::before { width: 64px; height: 64px; opacity: .08; }
  #view-calc .display-big { font-size: 34px; }
  #view-calc .keypad {
    flex: 0 0 58%;
    min-width: 0;
    grid-auto-rows: minmax(0, 1fr);
    gap: 6px;
    padding: 4px 10px 6px 8px;
  }
  #view-calc .keypad .key { max-height: none; border-radius: 14px; font-size: 18px; }
  #view-calc .keypad .key-op, #view-calc .keypad .key-eq { width: 46px; height: 46px; font-size: 16px; }
}

/* 키 소리 토글 */
#btn-sfx .sfx-slash { display: none; }
#btn-sfx.is-off .sfx-wave { display: none; }
#btn-sfx.is-off .sfx-slash { display: inline; }
#btn-sfx.is-off { opacity: .5; }

/* ---------- 키 소리 고르기 시트 ---------- */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(12, 40, 32, .34);
  opacity: 0;
  transition: opacity .18s ease;
  backdrop-filter: blur(2px);
}
.sheet.is-open { opacity: 1; }
.sheet-panel {
  width: 100%;
  max-width: 520px;
  max-height: 82vh;
  overflow-y: auto;
  background: #f7fdfa;
  border-radius: 26px 26px 0 0;
  padding: 8px 16px calc(20px + env(safe-area-inset-bottom));
  box-shadow: 0 -16px 40px rgba(12, 60, 45, .22);
  transform: translateY(14px);
  transition: transform .2s ease;
}
.sheet.is-open .sheet-panel { transform: translateY(0); }
.sheet-grab { width: 44px; height: 4px; border-radius: 999px; background: #cfe3d9; margin: 6px auto 10px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { margin: 0; font-size: 17px; font-weight: 700; color: #123c2e; }
.sheet-close { width: 36px; height: 36px; border: 0; background: #e8f4ee; border-radius: 50%; display: grid; place-items: center; }
.sheet-close svg { width: 18px; height: 18px; fill: none; stroke: #2f7d5f; stroke-width: 2.2; stroke-linecap: round; }
.sheet-note { margin: 10px 2px 12px; font-size: 12.5px; line-height: 1.5; color: #5d7a70; }
.sfx-switch-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  border: 0;
  border-radius: 14px;
  background: #d9f0e4;
  color: #14674a;
  font-size: 14px;
  font-weight: 700;
  margin: 4px 0 4px;
}
.sfx-switch-row.is-off { background: #eceeed; color: #7c8b85; }
.sfx-list { display: grid; gap: 8px; margin-top: 10px; }
.sfx-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: flex-start;
  text-align: left;
  padding: 12px 14px;
  border: 1.5px solid #e2efe8;
  border-radius: 15px;
  background: #ffffff;
  color: #17392e;
}
.sfx-item.is-on { border-color: #1f9c72; background: #eafaf3; box-shadow: 0 3px 10px rgba(20, 120, 88, .12); }
.sfx-item__name { font-size: 14.5px; font-weight: 700; }
.sfx-item__desc { font-size: 12px; color: #6b8479; }

/* ---------- 줄 합계 · 메모 · 사진 · 공유 ---------- */
.field-col { display: block; }
.field-col span { display: block; margin-bottom: 6px; }
.field textarea {
  width: 100%;
  border: 1.5px solid #e2efe8;
  border-radius: 14px;
  background: #fff;
  padding: 12px 14px;
  font: inherit;
  font-size: 15px;
  line-height: 1.5;
  color: #17392e;
  resize: vertical;
  box-sizing: border-box;
}
.field textarea:focus { outline: none; border-color: #1f9c72; box-shadow: 0 0 0 3px rgba(31,156,114,.12); }
.seg-row { display: flex; gap: 6px; margin: 8px 0 12px; }
.seg-row .seg {
  flex: 1 1 0;
  padding: 10px 8px;
  border: 1.5px solid #e2efe8;
  border-radius: 12px;
  background: #fff;
  color: #6b8479;
  font-size: 13.5px;
  font-weight: 600;
}
.seg-row .seg.is-active { border-color: #1f9c72; background: #eafaf3; color: #14674a; }
.act-row { display: flex; gap: 8px; margin: 10px 0 4px; }
.act-btn {
  flex: 1 1 0;
  padding: 12px 10px;
  border: 1.5px solid #dbeae2;
  border-radius: 14px;
  background: #fff;
  color: #17453a;
  font-size: 14px;
  font-weight: 700;
}
.act-btn--main { background: #1f9c72; border-color: #1f9c72; color: #fff; box-shadow: 0 6px 16px rgba(20,120,88,.22); }
.memo-title { margin: 18px 0 6px; font-size: 15px; font-weight: 700; color: #123c2e; }
.photo-strip { display: flex; gap: 8px; overflow-x: auto; padding: 8px 0 4px; scrollbar-width: none; }
.photo-strip::-webkit-scrollbar { display: none; }
.photo-item { position: relative; margin: 0; flex: 0 0 auto; }
.photo-item img { width: 84px; height: 84px; object-fit: cover; border-radius: 12px; border: 1px solid #e2efe8; display: block; }
.photo-del {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: #20443a;
  color: #fff;
  font-size: 14px;
  line-height: 1;
}
.record-list { display: grid; gap: 8px; margin-top: 10px; }
.record-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #e6f1eb;
  border-radius: 13px;
  background: #fbfefc;
}
.record-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.record-main b { font-size: 14.5px; color: #14674a; }
.record-main span { font-size: 11.5px; color: #75908a; }
.record-main em { font-size: 12px; color: #43594f; font-style: normal; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.record-acts { display: flex; gap: 6px; flex: 0 0 auto; }
.record-btn {
  padding: 7px 10px;
  border: 1px solid #dbeae2;
  border-radius: 10px;
  background: #fff;
  color: #17453a;
  font-size: 12px;
  font-weight: 700;
}
.record-btn--del { color: #b0473f; border-color: #f0dcd9; }
.act-btn--sm { flex: 0 0 auto; padding: 12px 12px; font-size: 13px; }
.act-btn--shot { background: #f2fbf7; border-color: #cfe9de; color: #14674a; }
.act-row { flex-wrap: nowrap; }
.act-btn--main { flex: 1 1 auto; }

/* ---------- 즐겨찾기 ---------- */
.icon-btn--fav svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.icon-btn--fav.is-on { color: #e0a11d; }
.icon-btn--fav.is-on svg { fill: #ffd062; stroke: #e0a11d; }
.fav-star {
  display: inline-block;
  margin-left: 3px;
  font-size: 11px;
  line-height: 1;
  color: #c8d6cf;
  vertical-align: 1px;
}
.fav-star.is-on { color: #e8a91b; }
.fav-star--btn {
  display: inline-grid;
  place-items: center;
  padding: 0 1px;
  border: 0;
  background: none;
  font-size: 11px;
  line-height: 1;
  color: #b9ccc3;
  vertical-align: 0;
}
.fav-star--btn.is-on { color: #e8a91b; }
.life-tab { display: inline-flex; align-items: center; gap: 2px; }
.brandbar__text { display: inline-flex; align-items: center; gap: 4px; }

/* ---------- 언어 고르기 시트 ---------- */
.lang-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 2px 2px 10px;
}
.lang-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-height: 50px;
  padding: 0 12px;
  border: 1px solid #dcebe3;
  border-radius: 14px;
  background: #fbfefc;
  color: #123c2e;
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  line-height: 1.2;
  overflow: hidden;
}
.lang-item__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lang-item.is-active { border-color: var(--accent); background: var(--accent-soft); color: #0b5f45; }
.lang-item__mark { flex: 0 0 auto; font-size: 13px; font-weight: 800; color: var(--accent); }
.fav-list { display: grid; gap: 8px; padding: 2px 2px 12px; max-height: 54vh; overflow-y: auto; }
.fav-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 12px 14px; border: 1px solid #e6f1eb;
  border-radius: 14px; background: #fbfefc;
}
.fav-row__go { flex: 1 1 auto; text-align: left; border: 0; background: none; font-size: 15px; font-weight: 600; color: #17453a; }
.fav-row__star { width: 40px; height: 40px; flex: 0 0 auto; border: 1px solid #e2efe8; border-radius: 12px; background: #fff; font-size: 17px; color: #c8d6cf; }
.fav-row__star.is-on { color: #e8a91b; border-color: #f5dfa6; background: #fffaf0; }
.fav-group-title { margin: 14px 4px 2px; font-size: 12.5px; font-weight: 700; color: #7b948a; }

/* 영수증 읽는 중 */
.ocr-wait { position: absolute; inset: 0; z-index: 70; display: grid; place-items: center; background: rgba(12,40,32,.34); backdrop-filter: blur(2px); }
.ocr-wait[hidden] { display: none; }
.ocr-wait__box { background: #fff; border-radius: 18px; padding: 22px 26px; box-shadow: 0 18px 40px rgba(9,45,34,.24); text-align: center; }
.ocr-wait__box p { margin: 12px 0 0; font-size: 14px; font-weight: 600; color: #17453a; }
.ocr-wait__spin { width: 30px; height: 30px; margin: 0 auto; border: 3px solid #dff0e8; border-top-color: #1f9c72; border-radius: 50%; animation: ocrspin .8s linear infinite; }
@keyframes ocrspin { to { transform: rotate(360deg); } }

/* ---------- 손글씨 계산 ---------- */
.write-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 2px 14px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.write-pad-card {
  flex: 0 0 auto;
  background: var(--surface);
  border-radius: 20px;
  padding: 10px 10px 8px;
  box-shadow: var(--shadow);
}

.write-pad-wrap {
  position: relative;
  height: clamp(210px, 40vh, 330px);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  touch-action: none;
  background-color: #fcfefd;
  background-image:
    linear-gradient(to right, rgba(18, 160, 106, .06) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(18, 160, 106, .06) 1px, transparent 1px),
    linear-gradient(to bottom, transparent calc(50% - .5px), rgba(18, 160, 106, .16) calc(50% - .5px), rgba(18, 160, 106, .16) calc(50% + .5px), transparent calc(50% + .5px));
  background-size: 28px 28px, 28px 28px, 100% 100%;
}
.write-pad-wrap.is-erase { background-color: #fff8f8; border-color: #f6d9d6; }

#write-pad {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

.write-placeholder {
  position: absolute;
  inset: 0;
  margin: 0;
  display: grid;
  place-content: center;
  gap: 4px;
  text-align: center;
  font-size: 13px;
  line-height: 1.6;
  color: #a9bdb4;
  pointer-events: none;
  transition: opacity .15s ease;
}
.write-placeholder b { color: #7fa396; font-weight: 700; }
.write-placeholder[hidden] { display: none; }

.write-tools {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.write-tool {
  flex: 1 1 0;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 40px;
  padding: 0 6px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: #f4f8f6;
  color: #46605a;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: -.2px;
  white-space: nowrap;
  transition: background .14s ease, color .14s ease, border-color .14s ease;
}
.write-tool svg { width: 16px; height: 16px; stroke-width: 1.9; flex: 0 0 auto; }
.write-tool:active { background: #e7f1ec; }
.write-tool.is-on { background: var(--accent-soft); border-color: #bfe6d6; color: var(--accent); }
.write-tool--red { color: #b0473f; background: #fdf3f2; }
.write-tool--red:active { background: #f9e4e1; }

.write-out { padding: 14px 14px 12px; }

.write-expr-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.write-expr-label {
  flex: 0 0 auto;
  font-size: 12.5px;
  font-weight: 600;
  color: #5b6472;
}
#write-expr {
  flex: 1 1 auto;
  min-width: 0;
  height: 46px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8f9fb;
  color: var(--text);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: .2px;
  outline: none;
  font-variant-numeric: tabular-nums;
  transition: border-color .15s ease, background .15s ease;
}
#write-expr::placeholder { color: #b3b8c1; font-size: 13px; font-weight: 500; }
#write-expr:focus { border-color: var(--accent); background: #fff; }
#write-expr.is-bad { border-color: #f0b6b4; background: #fffafa; }

#write-expr { padding-right: 10px; }
.write-redo {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  transition: background .14s ease, transform .08s ease;
}
.write-redo svg { width: 20px; height: 20px; stroke-width: 1.9; }
.write-redo:active { background: #d4eede; transform: scale(.94); }

.write-status {
  margin: 8px 2px 0;
  min-height: 1.35em;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--muted);
  word-break: keep-all;
}
.write-status.is-busy { color: var(--accent); }
.write-status.is-err { color: #c4554c; }

.write-cands {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px dashed var(--line);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
  -webkit-mask-image: linear-gradient(90deg, #000 0, #000 96%, transparent 100%);
  mask-image: linear-gradient(90deg, #000 0, #000 96%, transparent 100%);
}
.write-cands::-webkit-scrollbar { display: none; }
.write-cands[hidden] { display: none; }
.wchip {
  flex: 0 0 auto;
  max-width: 78%;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: #2c443b;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .2px;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wchip:active { background: #eef4f1; }
.wchip.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.write-cands.is-ambig .wchip { font-size: 17px; padding: 11px 16px; border-radius: 14px; }

.write-result {
  margin-top: 12px;
  padding: 12px 14px 14px;
  border-radius: 16px;
  background: linear-gradient(160deg, #e9f9f1 0%, #dff3ea 100%);
  border: 1px solid #cceade;
  animation: fade-in .18s ease;
}
.write-result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.write-result-head span { font-size: 12.5px; font-weight: 600; color: #4d6b60; }
.write-result-head .mini-btn { padding: 6px 10px; font-size: 12px; }
.write-result-value {
  margin-top: 2px;
  font-family: var(--font-num);
  font-size: 38px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -.5px;
  color: var(--accent);
  text-align: right;
  overflow-x: auto;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  scrollbar-width: none;
}
.write-result-value::-webkit-scrollbar { display: none; }
.write-result-kr {
  margin-top: 1px;
  text-align: right;
  font-size: 13px;
  font-weight: 600;
  color: #4d6b60;
}
.write-result-kr:empty { display: none; }

.write-privacy {
  margin: 12px 2px 0;
  font-size: 11px;
  line-height: 1.5;
  color: #93a29c;
  word-break: keep-all;
}

/* 아이콘 줄이 좁은 화면에서 넘치지 않게 */
@media (max-width: 470px) {
  .topbar { padding-left: 6px; padding-right: 6px; }
  .topbar .icon-btn { width: 37px; height: 37px; }
  .topbar .icon-btn svg { width: 19px; height: 19px; }
  .icon-btn--lang { font-size: 11px; }
}

@media (max-width: 400px) {
  .topbar .icon-btn { width: 34px; height: 34px; }
  .topbar .icon-btn svg { width: 18px; height: 18px; }
  .write-tool { font-size: 12px; gap: 3px; }
  .write-tool svg { width: 15px; height: 15px; }
}
@media (max-width: 360px) {
  .topbar .icon-btn { width: 30px; height: 30px; }
  .topbar .icon-btn svg { width: 16px; height: 16px; }
  .icon-btn--lang { font-size: 10px; }
  .write-tool { font-size: 11px; gap: 2px; padding: 0 3px; }
}

/* ---------- 언어 바꾸기 버튼 (별표 오른쪽 끝) ---------- */
.icon-btn--lang {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #0e6b4d;
  border: 1px solid #cfe9dd;
  background: #f2fbf7;
}
.icon-btn--lang:active { background: #dff3ea; }
.icon-btn--lang svg { display: none; }
.icon-btn--lang span { line-height: 1; }

/* ---------- 하위 화면 즐겨찾기 별표 (subhead 오른쪽 끝) ---------- */
.subhead h1 {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fav-star-btn {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  margin-left: auto;
  color: #b9ccc3;
}
.fav-star-btn svg { width: 23px; height: 23px; }
.fav-star-btn svg path { fill: none; }
.fav-star-btn.is-on { color: #e0a11d; }
.fav-star-btn.is-on svg path { fill: #ffd062; stroke: #e0a11d; }
@media (max-width: 400px) {
  .fav-star-btn { width: 38px; height: 38px; }
  .fav-star-btn svg { width: 21px; height: 21px; }
}

/* ---------- 맨 아래 문의 줄 ---------- */
.contact-line {
  flex: 0 0 auto;
  margin: 0;
  padding: 0 12px calc(4px + env(safe-area-inset-bottom));
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: -0.01em;
}
.contact-line a {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 10px;
  color: #0e6b4d;
  font-weight: 600;
  text-decoration: none;
}
.contact-line a:active { background: rgba(18, 160, 106, .12); }
/* =====================================================================
   2026-11-27 v4 — 원색 팔레트 · 전 화면 가운데 정렬 · 아이콘 확대
   ---------------------------------------------------------------------
   대장 님 지시: "색깔들을 더 이쁘게, 테두리 색깔이라든지 테두리 안에
   색을 넣는다든지, 좀 더 원색으로. 너무 밋밋해." / "전부 왼쪽으로
   쏠렸네, 가운데로 와야지." / "아이콘이 너무 작아, 조금 더 키워."
   값은 위 :root 한 곳에서만 관리한다.
   ===================================================================== */

/* ---------- A. 맨 위 줄 · 이름표 · 아이콘 줄 ---------- */
.topstrip {
  height: calc(36px + env(safe-area-inset-top));
  padding: calc(env(safe-area-inset-top)) 6px 0;
}
.icon-btn--lang {
  width: 44px;
  height: 30px;
  border: 1.6px solid #bcd2ee;
  border-radius: 10px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: .02em;
}

.brandbar {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 0;
  height: 40px;
  padding: 0 6px;
  font-size: 16px;
  font-weight: 800;
  color: var(--text-2);
}
.brandbar__title { grid-column: 2; grid-row: 1; justify-self: center; gap: 5px; }
#btn-fav { grid-column: 3; grid-row: 1; justify-self: end; }

/* 이름표와 언어 버튼을 한 줄에 수평으로 (2026-11-27 대장 님 지시) */
.topstrip { display: none; }
.brandbar {
  padding-top: env(safe-area-inset-top);
  height: calc(40px + env(safe-area-inset-top));
}
#btn-lang { grid-column: 3; grid-row: 1; justify-self: end; align-self: center; }
.brandbar__text { font-weight: 800; letter-spacing: -.2px; font-size: 16px; }
.icon-btn--brand { width: 34px; height: 30px; color: var(--purple); }
.icon-btn--brand svg { width: 19px; height: 19px; }
.fav-star--btn { font-size: 12px; color: #b9c6d8; }
.fav-star--btn.is-on { color: #e0a11d; }

/* 아이콘 줄: 버튼 폭을 같게 두고 space-between 하나로만 균등 배치.
   (시계·스피커만 벌어지던 개별 여백·인라인 폭 차이를 없앤다) */
.topbar {
  justify-content: space-between;
  gap: 0;
  min-height: 46px;
  padding: 0 6px;
}
.topbar .icon-btn {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 14px;
}
.topbar .icon-btn svg { width: 23px; height: 23px; stroke-width: 2; }
/* 아이콘마다 원색 하나씩 (한 줄에 5색 이내, 이웃끼리 다른 색) */
#view-calc .topbar .icon-btn:nth-child(5n+1) { color: var(--teal); }
#view-calc .topbar .icon-btn:nth-child(5n+2) { color: var(--green); }
#view-calc .topbar .icon-btn:nth-child(5n+3) { color: var(--blue); }
#view-calc .topbar .icon-btn:nth-child(5n+4) { color: var(--purple); }
#view-calc .topbar .icon-btn:nth-child(5n+5) { color: var(--orange); }
#view-calc .topbar .icon-btn:active { background: var(--blue-soft); transform: scale(.94); }
/* 켜짐/꺼짐은 채움으로 구분 */
.icon-btn.is-on {
  background: var(--blue-soft);
  color: var(--blue);
}
.icon-btn.is-on svg { fill: currentColor; fill-opacity: .22; }
.icon-btn--fav.is-on { background: #fff7e2; color: #b57b09; }
.icon-btn--fav.is-on svg { fill: #ffd062; stroke: #b57b09; }

/* ---------- B. 하위 화면 헤더: 제목+별표 묶음을 가운데 ---------- */
.subhead {
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 56px;
  padding: calc(4px + env(safe-area-inset-top)) 6px 4px;
}
.subhead__mid {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 0;
}
.subhead h1 {
  flex: 0 1 auto;
  margin: 0;
  text-align: center;
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -.4px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.subhead__gap { flex: 0 0 44px; width: 44px; }
.subhead > .icon-btn:first-child { color: var(--text-2); }
/* 제목 바로 뒤 작은 별표 — 평소 옅은 회색, 담으면 금색 */
.fav-star-btn {
  width: 38px;
  height: 38px;
  margin-left: 0;
  color: #c2cedd;
  position: relative;
}
.fav-star-btn::before { content: ""; position: absolute; inset: -5px; border-radius: 14px; }
.fav-star-btn svg { width: 20px; height: 20px; }
.fav-star-btn.is-on { color: #d29109; background: #fff8e6; }
.fav-star-btn.is-on svg path { fill: #ffd062; stroke: #d29109; }

/* ---------- C. 탭: 원색 테두리 + 옅은 채움 / 선택은 진한 배경 + 흰 글자 ---------- */
.life-tabs { gap: 7px; padding: 4px 12px 12px; }
.life-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 10px 14px;
  border: 1.6px solid #bcd2ee;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -.3px;
  text-align: center;
  box-shadow: none;
}
.life-tab.is-active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  box-shadow: 0 6px 14px rgba(11, 95, 208, .28);
}
.life-tab.is-active .tab-star { color: rgba(255, 255, 255, .55); }
.life-tab.is-active .tab-star.is-on { color: #ffd062; }
.life-tab__t { white-space: nowrap; }
/* 탭마다 붙는 작은 별표 (평소 옅은 회색 → 담으면 금색) */
.tab-star {
  flex: 0 0 auto;
  font-size: 10px;
  line-height: 1;
  font-style: normal;
  color: #a9bdd8;
  padding: 2px 1px;
  transition: color .14s ease, transform .1s ease;
}
.tab-star.is-on { color: #e0a11d; }
.tab-star:active { transform: scale(1.25); }
/* 생활 탭(11개)은 스크롤 — 끝 탭의 별표까지 잘리지 않게 */
#life-tabs { padding-right: 18px; }
#life-tabs .life-tab { padding: 10px 12px; font-size: 14.5px; }

/* 스마트 탭: 5개를 줄 전체에 균등 배분(가운데 정렬) */
.smart-tabs .life-tab { padding: 10px 4px; font-size: 13.5px; gap: 2px; }

/* ---------- D. 카드 · 라벨 · 결과: 색 테두리와 가운데 정렬 ---------- */
.card {
  border: 1.6px solid var(--line);
  border-radius: 20px;
  padding: 16px 14px 14px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
  box-shadow: 0 1px 2px rgba(15, 45, 90, .04), 0 10px 22px rgba(15, 45, 90, .06);
  text-align: center;
}
.card h2 {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -.3px;
  text-align: center;
  color: var(--text);
}
.card h3, .memo-title { text-align: center; font-weight: 800; color: var(--text-2); }
.hint {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.6;
  color: var(--muted);
  text-align: center;
}
.note { text-align: center; font-size: 12.5px; color: var(--muted); }
/* 세 줄 넘는 긴 안내만 왼쪽 */
.hint--long { text-align: left; }

.field {
  justify-content: center;
  gap: 10px;
  padding: 11px 4px;
  border-bottom: 1.5px dashed #dbe6f5;
}
.field span:first-child {
  flex: 0 0 auto;
  min-width: 74px;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-2);
}
.field input { text-align: center; font-size: 21px; font-weight: 700; }
.field .won { text-align: center; font-weight: 700; color: var(--muted); }
.field:focus-within { border-bottom-color: var(--blue); }
.field:focus-within span:first-child { color: var(--blue); }

.result-main {
  background: var(--green-soft);
  border: 1.6px solid #b7e3ce;
  border-radius: 16px;
  justify-content: center;
  gap: 10px;
}
.result-main span { font-size: 14px; font-weight: 800; color: var(--green-deep); text-align: center; }
.result-main strong { font-size: 24px; font-weight: 800; color: var(--green-deep); }
.result-main strong.loss { color: var(--orange-deep); }
.result-grid div {
  background: var(--blue-soft);
  border: 1.4px solid #c9dcf5;
  border-radius: 14px;
  justify-content: center;
  gap: 8px;
}
.result-grid span { font-size: 13px; font-weight: 700; color: #2f4a6b; text-align: center; }
.result-grid b { font-size: 16px; font-weight: 800; color: var(--text); }

.steps li span { color: var(--text-2); font-weight: 600; }
.steps li.is-total b { color: var(--green-deep); }
.eq-out { background: var(--purple-soft); border: 1.5px solid #d6c2f8; color: var(--purple-deep); text-align: center; }
.eq-out.small { color: var(--purple); }
.graph-read { color: var(--text-2); font-weight: 600; }
.coef { border-color: #c9dcf5; background: var(--blue-soft); }
.coef span { color: #2f4a6b; font-weight: 800; }
.lin-row { color: var(--text-2); font-weight: 600; }
.graph-wrap { border-color: #c9dcf5; }

/* ---------- E. 계산기 키패드 ---------- */
.display {
  min-height: 104px;
  margin: 0 10px 8px;
  background: linear-gradient(150deg, #0b2a52 0%, #123f78 55%, #0b5fd0 130%);
  box-shadow: 0 14px 30px rgba(10, 50, 110, .3), inset 0 1px 0 rgba(255, 255, 255, .14);
}
.display .display-expr { color: #bcd4f5; }
.display .display-kr { color: #ffd166; font-weight: 800; }
.display-big { color: #fff; font-size: 40px; font-weight: 600; }

.keypad { gap: 7px; padding: 2px 9px 6px; }
.key {
  border: 0;
  border-radius: var(--radius-key);
  font-size: 21px;
  font-weight: 700;
  color: var(--text);
}
.keypad .key:not(.key-op):not(.key-eq) {
  background: #f9fcff;
  border: 1.6px solid #c3d8f3;
  box-shadow: 0 1px 0 rgba(11, 95, 208, .07), 0 6px 14px rgba(15, 45, 90, .07);
}
.keypad .key[data-key="pct"] {
  background: var(--teal-soft);
  border-color: #a9d8e3;
  color: var(--teal-deep);
}
.key-paren {
  background: var(--purple-soft) !important;
  border-color: #d3bdf7 !important;
  color: var(--purple-deep) !important;
}
.key-red {
  background: var(--orange-soft) !important;
  border-color: #f0b48e !important;
  color: var(--orange-deep) !important;
}
.key:active { background: var(--blue-soft); transform: scale(.965); }
.key-op {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: var(--blue);
  border: 0;
  color: #fff;
  font-weight: 700;
  box-shadow: 0 8px 16px rgba(11, 95, 208, .3), inset 0 1px 0 rgba(255, 255, 255, .28);
}
.key-op:active { background: var(--blue-deep); }
.key-eq {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: var(--blue-deep);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 10px 20px rgba(10, 63, 150, .4), inset 0 1px 0 rgba(255, 255, 255, .24);
}
.key-eq:active { background: #082f6f; }
.keypad .key-op, .keypad .key-eq { height: 62px; width: 62px; }

.sci-key {
  background: var(--purple-soft);
  border: 1.4px solid #d6c2f8;
  color: var(--purple-deep);
  font-weight: 700;
  font-size: 15px;
}
.sci-key:active { background: #e6d8ff; }
.sci-key.is-on { background: var(--purple); border-color: var(--purple); color: #fff; }

/* ---------- F. 버튼류 ---------- */
.act-btn {
  border: 1.6px solid #b7e3ce;
  background: var(--green-soft);
  color: var(--green-deep);
  font-size: 15px;
  font-weight: 800;
  border-radius: 14px;
  text-align: center;
  justify-content: center;
}
.act-btn--main {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
  box-shadow: 0 8px 18px rgba(10, 125, 82, .26);
}
.act-btn--sm { font-size: 13.5px; }
.act-btn--shot { background: var(--blue-soft); border-color: #bcd2ee; color: var(--blue); }
.act-btn:active { transform: scale(.98); }
.mini-btn {
  border: 1.4px solid #bcd2ee;
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 800;
  font-size: 13px;
}
.chip {
  border: 1.4px solid #bcd2ee;
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 700;
  font-size: 13px;
}
.chip:active { background: #d8e6ff; }
.demo-row .chip { background: var(--blue-soft); }
.seg { background: var(--surface-2); border-color: var(--line); }
.seg-btn { color: var(--text-2); font-weight: 700; font-size: 14px; }
.seg-btn.is-active { background: var(--blue); color: #fff; border-color: var(--blue); }
.seg-row .seg.is-active { border-color: var(--blue); background: var(--blue); color: #fff; }
.switch i { background: #c9d6e8; }
.switch input:checked + i { background: var(--blue); }
.record-btn { border-color: #bcd2ee; color: var(--blue); background: var(--blue-soft); font-weight: 700; }
.record-btn--del { border-color: #f0b48e; color: var(--orange-deep); background: var(--orange-soft); }

/* ---------- G. 시트 ---------- */
.sheet-panel {
  border: 1.6px solid var(--line);
  border-top: 3px solid var(--blue);
}
.sheet-head { position: relative; justify-content: center; }
.sheet-head h2 {
  text-align: center;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -.3px;
  color: var(--text);
}
.sheet-close {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1.4px solid var(--line);
  background: var(--surface-2);
  color: var(--text-2);
}
.sheet-note { text-align: center; font-size: 13px; color: var(--text-2); font-weight: 500; }
.lang-item {
  border: 1.6px solid #c9dcf5;
  background: #f8fbff;
  color: var(--text);
  font-size: 14.5px;
  font-weight: 700;
  justify-content: center;
  gap: 8px;
}
.lang-item__name { text-align: center; }
.lang-item.is-active { border-color: var(--blue); background: var(--blue); color: #fff; }
.lang-item.is-active .lang-item__mark { color: #fff; }
.lang-item__mark { color: var(--blue); }

.fav-row { border-color: #c9dcf5; background: #f8fbff; justify-content: center; }
.fav-row__go { text-align: center; font-weight: 700; color: var(--text); }
.fav-row__star { border-color: #c9dcf5; background: #fff; color: #b9c6d8; width: 42px; height: 42px; }
.fav-row__star.is-on { color: #d29109; border-color: #f2d79a; background: #fff8e6; }
.fav-group-title { text-align: center; color: var(--text-2); font-weight: 800; }
.fav-empty {
  margin: 4px 2px 10px;
  padding: 16px 14px;
  border: 1.6px dashed #c9dcf5;
  border-radius: 16px;
  background: #f8fbff;
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.6;
  text-align: center;
}

/* ---------- H. 카메라 안내 패널 ---------- */
.cam-panel { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
.cam-hero {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin: 6px auto 10px;
  border-radius: 20px;
  background: var(--blue);
  color: #fff;
  box-shadow: 0 10px 22px rgba(11, 95, 208, .3);
}
.cam-hero svg { width: 34px; height: 34px; stroke-width: 1.9; }
.cam-desc {
  margin: 0 0 10px;
  padding: 0 6px;
  text-align: center;
  font-size: 16.5px;
  font-weight: 800;
  line-height: 1.5;
  letter-spacing: -.3px;
  color: var(--text);
}
.cam-tips {
  margin: 0 0 10px;
  padding: 12px 12px;
  list-style: none;
  border: 1.5px solid #c9dcf5;
  border-radius: 16px;
  background: var(--blue-soft);
  display: grid;
  gap: 7px;
}
.cam-tips li {
  text-align: center;
  font-size: 13.5px;
  font-weight: 700;
  color: #1f3f6b;
}
.cam-tips li::before {
  content: "\2022";
  color: var(--blue);
  font-weight: 900;
  margin-right: 5px;
}
.cam-note {
  margin: 0 0 14px;
  text-align: center;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.55;
  color: var(--muted);
}
.cam-acts { display: flex; gap: 8px; }
.cam-btn {
  flex: 1 1 0;
  min-height: 52px;
  border-radius: 16px;
  font-size: 17px;
  font-weight: 800;
  border: 1.6px solid transparent;
}
.cam-btn--ghost { flex: 0 0 34%; border-color: var(--line); background: var(--surface-2); color: var(--text-2); }
.cam-btn--main {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 10px 20px rgba(11, 95, 208, .3);
}
.cam-btn:active { transform: scale(.98); }

/* ---------- I. 손글씨 화면도 가운데 ---------- */
.write-body { text-align: center; }
.write-tool {
  border: 1.5px solid #c9dcf5;
  background: #f8fbff;
  color: var(--text-2);
  font-weight: 700;
  font-size: 13px;
  justify-content: center;
}
.write-tool--red { border-color: #f0b48e; background: var(--orange-soft); color: var(--orange-deep); }
.write-tool.is-on { border-color: var(--blue); background: var(--blue-soft); color: var(--blue); }
.write-placeholder { text-align: center; }
.write-expr-row { justify-content: center; gap: 8px; }
.write-expr-label { text-align: center; font-weight: 700; color: var(--text-2); }
#write-expr { text-align: center; font-weight: 700; }
.write-status { text-align: center; color: var(--text-2); font-weight: 600; }
.write-cands { justify-content: center; text-align: center; }
.wchip { border-color: #c9dcf5; background: #f8fbff; color: var(--text); font-weight: 700; }
.wchip.is-active { background: var(--blue); border-color: var(--blue); color: #fff; }
.write-result { text-align: center; }
.write-result-head { justify-content: center; gap: 10px; }
.write-result-value { text-align: center; color: var(--blue-deep); }
.write-result-kr { text-align: center; }
.write-privacy { text-align: center; color: var(--muted); }
.write-pad-card { border-color: var(--line); }
.unit-cats { justify-content: safe center; gap: 6px; padding-left: 12px; padding-right: 12px; }
.cat {
  border: 1.5px solid #c9dcf5;
  background: #f8fbff;
  color: var(--text-2);
  font-weight: 700;
  font-size: 14px;
}
.cat.is-active { background: var(--blue); border-color: var(--blue); color: #fff; }

/* ---------- J. 좁은 화면: 아이콘 10개가 한 줄에, 터치 40px 이상 ---------- */
@media (max-width: 360px) {
  .topbar { padding: 0; }
  .topbar .icon-btn { width: 40px; height: 44px; border-radius: 12px; }
  .topbar .icon-btn svg { width: 22px; height: 22px; }
  .brandbar { grid-template-columns: 30px minmax(0, 1fr) 44px; height: calc(38px + env(safe-area-inset-top)); font-size: 14px; }
  .display { min-height: 96px; }
  .display-big { font-size: 36px; }
  .life-tab { font-size: 14px; padding: 9px 10px; }
  #life-tabs .life-tab { font-size: 13.5px; padding: 9px 10px; }
  .smart-tabs .life-tab { font-size: 12.5px; padding: 9px 2px; }
  .subhead h1 { font-size: 19px; }
  .cam-desc { font-size: 15px; }
  .cam-tips li { font-size: 12.5px; }
}

/* ---------- K. v4 미세 조정 ---------- */
/* 어두운 표시부 안의 숫자만 흰색 (공학 표시부는 밝은 바탕이라 그대로 둔다) */
.display-big { color: var(--text); }
.display .display-big { color: #fff; }
/* 스위치 줄·입력 줄도 가운데 */
.tts-row { justify-content: center; gap: 10px; }
.tts-row span { font-weight: 700; color: var(--text-2); text-align: center; }
.smart-input { justify-content: center; }
.write-expr-row { justify-content: center; }
.write-expr-label { flex: 0 0 auto; }
.write-expr-row #write-expr { flex: 1 1 auto; max-width: 58%; }

/* 시트 제목은 가운데, 닫기 버튼은 오른쪽 고정 */
.sheet-head { justify-content: center; }
.sheet-head h2 { flex: 1 1 auto; width: 100%; text-align: center; }
/* 카메라 안내는 내용만큼만 높이를 쓴다 */
.cam-panel { height: auto; max-height: 86vh; }
@media (max-width: 360px) {
  .cam-panel { padding-left: 12px; padding-right: 12px; }
}
/* 언어·즐겨찾기 시트도 내용만큼만 (기록 시트는 목록이 길어 그대로) */
#lang-sheet .sheet-panel, #fav-sheet .sheet-panel { height: auto; max-height: 86vh; }
.fav-empty, .sheet-note, .hint, .note, .cam-note, .cam-desc { word-break: keep-all; }

/* 단위 계산기 키패드도 같은 팔레트 */
.u-key {
  background: #f9fcff;
  border: 1.6px solid #c3d8f3;
  box-shadow: 0 1px 0 rgba(11, 95, 208, .07), 0 6px 14px rgba(15, 45, 90, .07);
  color: var(--text);
  font-weight: 700;
}
.u-key:active { background: var(--blue-soft); }
.u-key.u-red { background: var(--orange-soft); border-color: #f0b48e; color: var(--orange-deep); }
.u-key.u-arrow { background: var(--blue); border-color: var(--blue); color: #fff; }
.u-key.u-arrow:active { background: var(--blue-deep); }
.u-key.u-arrow.is-on { box-shadow: 0 0 0 3px rgba(11, 95, 208, .2), 0 8px 18px rgba(11, 95, 208, .3); }
.unit-row { text-align: center; }
.unit-pick { justify-content: center; }
.unit-value { color: var(--text); }

/* ---------- L. 키 소리 설정: 큰 토글 + 또렷한 목록 ---------- */
#sfx-sheet .sheet-panel { height: auto; max-height: 88vh; }
#sfx-sheet .sheet-head h2 { font-size: 20px; font-weight: 800; }
.sfx-switch-row {
  height: 60px;
  border-radius: 18px;
  border: 2.5px solid var(--green-deep);
  background: var(--green);
  color: #fff;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: .02em;
  box-shadow: 0 8px 18px rgba(10, 125, 82, .28);
  margin: 2px 0 6px;
}
.sfx-switch-row::after {
  content: "";
  width: 12px;
  height: 12px;
  margin-left: 10px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, .28);
}
.sfx-switch-row.is-off {
  background: #dde5f1;
  border-color: #8798b3;
  color: #21324b;
  box-shadow: none;
}
.sfx-switch-row.is-off::after {
  background: #8798b3;
  box-shadow: 0 0 0 4px rgba(135, 152, 179, .22);
}
.sfx-list { gap: 10px; margin-top: 6px; }
.sfx-item {
  min-height: 58px;
  align-items: center;
  text-align: center;
  justify-content: center;
  gap: 3px;
  padding: 12px 16px;
  border: 1.8px solid #bcd2ee;
  border-radius: 16px;
  background: #f8fbff;
  color: var(--text);
}
.sfx-item__name { font-size: 16px; font-weight: 800; letter-spacing: -.2px; }
.sfx-item__name::after { content: ""; }
.sfx-item__desc { font-size: 13px; font-weight: 600; color: var(--muted); }
.sfx-item.is-on {
  border: 2.6px solid var(--blue-deep);
  background: var(--blue);
  color: #fff;
  box-shadow: 0 8px 18px rgba(11, 95, 208, .28);
}
.sfx-item.is-on .sfx-item__name { font-weight: 900; }
.sfx-item.is-on .sfx-item__name::after { content: " ✓"; font-weight: 900; }
.sfx-item.is-on .sfx-item__desc { color: rgba(255, 255, 255, .92); }
.sfx-item:active { transform: scale(.99); }

/* 탭 별표를 조금 더 키워 누르기 쉽게, 글자 뒤 4~6px */
.life-tab { gap: 5px; }
.tab-star { font-size: 12.5px; padding: 3px 2px; }
.fav-star-btn svg { width: 22px; height: 22px; }
.fav-star--btn { font-size: 14px; }

/* ---------- M. 계산 기록 시트: 제목 가운데 + 항목 카드 ---------- */
#history .sheet-panel { height: auto; max-height: 86vh; }
#history .sheet-panel header { padding: 0 0 6px; }
#history .hist-item-wrap {
  border: 1.5px solid #c9dcf5;
  border-radius: 16px;
  background: #f8fbff;
  padding: 4px 6px 2px;
  margin-bottom: 8px;
}
#history .hist-item { text-align: center; padding: 8px 8px 4px; }
#history .hist-expr { font-size: 13.5px; font-weight: 600; color: var(--text-2); text-align: center; }
#history .hist-res { font-size: 22px; font-weight: 800; color: var(--blue-deep); text-align: center; }
#history .hist-memo { background: var(--blue-soft); color: var(--blue-deep); text-align: center; }
#history .hist-foot { justify-content: center; margin-top: 0; }
#history .memo-btn { color: var(--blue); font-weight: 700; font-size: 12.5px; }
#history .hist-empty { text-align: center; color: var(--text-2); font-weight: 600; padding: 20px 8px; }
#history footer { padding: 6px 4px 4px; }
#history #history-clear {
  width: 100%;
  min-height: 48px;
  border: 1.6px solid #f0b48e;
  border-radius: 14px;
  background: var(--orange-soft);
  color: var(--orange-deep);
  font-size: 15px;
  font-weight: 800;
}
/* 시트 제목 줄의 비대칭 여백을 없애 제목이 정확히 가운데 오게 */
.sheet-head, .sheet-panel header { padding-left: 0; padding-right: 0; }

/* ---------- 영수증 읽기 결과: 총금액이 맨 위에 크게, 그 아래 품목 (2026-11-28) ----------
   대장 님: "찍으면은 총금액이 얼마입니다, 이런 식으로 딱 계산을 해야지."
   날짜·카드번호·승인번호·포인트는 이 패널에 아예 나오지 않는다. */
.ocr-panel {
  margin: 14px 0 6px;
  padding: 10px 10px 12px;
  border: 1.6px solid #b7e3ce;
  border-radius: 18px;
  background: linear-gradient(180deg, #f1fdf8 0%, #e6f8ef 100%);
  text-align: center;
}
.ocr-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 2px 7px;
  margin: 0;
  padding: 12px 8px 11px;
  border: 1.6px solid #9fd9bf;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(10, 125, 82, .06), 0 8px 18px rgba(10, 125, 82, .08);
}
.ocr-hero__label { font-size: 15px; font-weight: 800; color: var(--green-deep); letter-spacing: -.2px; }
.ocr-hero__line { display: inline-flex; align-items: baseline; }
.ocr-hero__amount {
  font-family: var(--font-num);
  font-size: clamp(25px, 8.2vw, 36px);
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -.8px;
  color: var(--green-deep);
  word-break: keep-all;
}
.ocr-hero__suffix { font-size: 17px; font-weight: 800; color: var(--green-deep); }
.ocr-check { margin: 8px 2px 2px; font-size: 11.5px; font-weight: 600; line-height: 1.55; color: var(--muted); word-break: keep-all; }
.ocr-check.is-diff { color: var(--orange-deep); }
.ocr-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 12px 3px 4px; }
.ocr-head__title { margin: 0; font-size: 14px; font-weight: 800; color: var(--text-2); letter-spacing: -.2px; }
.ocr-head__count { font-size: 12px; font-weight: 700; color: var(--muted); }
.ocr-items { list-style: none; margin: 0; padding: 0; }
.ocr-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 2px;
  border-bottom: 1.4px dashed #cbe7da;
  text-align: left;
}
.ocr-row:last-child { border-bottom: 0; }
.ocr-row__body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 0;
  padding: 2px 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.ocr-row__name {
  flex: 0 1 auto;
  min-width: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  overflow-wrap: anywhere;
  word-break: keep-all;
}
.ocr-row__name.is-missing { color: var(--orange-deep); font-weight: 800; }
.ocr-row__dots { flex: 1 1 auto; min-width: 10px; border-bottom: 1.6px dotted #b4d6c6; transform: translateY(-3px); }
.ocr-row__amt {
  flex: 0 0 auto;
  font-family: var(--font-num);
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  white-space: nowrap;
  letter-spacing: -.3px;
}
.ocr-row__conf {
  flex: 0 0 auto;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 800;
  line-height: 1.5;
  letter-spacing: -.2px;
  white-space: nowrap;
}
.ocr-row__conf.is-high { background: var(--green-soft); color: var(--green-deep); }
.ocr-row__conf.is-mid { background: var(--blue-soft); color: var(--blue); }
.ocr-row__conf.is-low { background: var(--orange-soft); color: var(--orange-deep); }
.ocr-row__edit {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1.4px solid #cbe7da;
  border-radius: 10px;
  background: #fff;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}
.ocr-row.is-low .ocr-row__name,
.ocr-row.is-low .ocr-row__amt { opacity: .72; }
.ocr-row.is-off .ocr-row__name,
.ocr-row.is-off .ocr-row__amt { opacity: .38; text-decoration: line-through; }
.ocr-row.is-off .ocr-row__conf { opacity: .5; }
.ocr-row.is-editing { gap: 6px; }
.ocr-edit__name,
.ocr-edit__amt {
  height: 38px;
  padding: 0 8px;
  border: 1.5px solid #9fd9bf;
  border-radius: 10px;
  background: #fff;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.ocr-edit__name { flex: 1 1 auto; min-width: 0; }
.ocr-edit__amt { flex: 0 0 92px; width: 92px; text-align: right; font-family: var(--font-num); }
.ocr-edit__ok {
  flex: 0 0 auto;
  height: 38px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: var(--green);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}
.ocr-empty { margin: 14px 4px 6px; font-size: 13.5px; font-weight: 700; color: var(--muted); word-break: keep-all; }
.ocr-apply { margin: 10px auto 2px; display: block; }

/* 고치기 버튼 아이콘 */
.ocr-row__edit svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; display: block; margin: 0 auto; }

/* =========================================================
   카메라 계산 (찍은 사진을 읽고 답한다) — 2026-11-30
   ========================================================= */
#view-scene .life-body { padding-bottom: 28px; }
.sc-card { display: flex; flex-direction: column; gap: 4px; }
.sc-guide { display: flex; flex-direction: column; }
.sc-guide .cam-acts { display: flex; gap: 8px; margin-top: 8px; }

.sc-wait { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 26px 0 22px; }
.sc-wait p { margin: 0; font-size: 14px; font-weight: 700; color: var(--text-2); }

.sc-shot { margin: 0 0 8px; }
.sc-shot img { display: block; width: 100%; max-height: 148px; object-fit: contain; border-radius: 14px; background: var(--surface-2); }

.sc-src { margin: 0 0 8px; font-size: 12px; font-weight: 700; color: var(--muted); }

.sc-ask { margin: 6px 0 10px; padding: 12px 13px; border-radius: 14px; background: #fff6e0; border: 1.5px solid #f0c65c; }
.sc-ask p { margin: 0 0 8px; font-size: 13.5px; font-weight: 800; line-height: 1.5; color: #7a4d00; word-break: keep-all; }
.sc-cands { display: flex; flex-direction: column; gap: 6px; }
.sc-cand { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%;
  padding: 9px 11px; border: 1.5px solid #e6d8b4; border-radius: 11px; background: #fff;
  font-size: 13px; font-weight: 700; color: var(--text); text-align: left; cursor: pointer; }
.sc-cand b { font-family: var(--font-num); font-size: 14px; color: var(--blue); }
.sc-cand span { color: var(--muted); font-weight: 600; }

.sc-fields { display: flex; flex-direction: column; gap: 7px; margin: 4px 0 2px; }
.sc-field { display: grid; grid-template-columns: 74px 1fr auto; align-items: center; gap: 8px; }
.sc-field__k { font-size: 13.5px; font-weight: 700; color: var(--text-2); text-align: left; }
.sc-field__in { width: 100%; height: 42px; padding: 0 10px; border: 1.5px solid var(--line); border-radius: 11px;
  background: #fff; font-size: 16px; font-weight: 700; color: var(--text); text-align: right; font-family: var(--font-num); }
.sc-field__in:focus { outline: 2px solid var(--blue-soft); border-color: var(--blue); }
.sc-field__u { font-size: 12.5px; color: var(--muted); min-width: 30px; }
.sc-field__badge { grid-column: 2 / 4; justify-self: end; margin-top: -2px; font-size: 11px; font-weight: 800;
  padding: 2px 8px; border-radius: 999px; background: #fff1d6; color: #8a5300; }
.sc-field__badge.is-ok { background: var(--green-soft); color: var(--green-deep); }

.sc-table-wrap { overflow-x: auto; margin-top: 12px; }
.sc-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.sc-cap { caption-side: top; text-align: left; font-size: 12px; font-weight: 800; color: var(--muted); padding-bottom: 4px; }
.sc-table th { padding: 6px 3px; font-size: 11.5px; font-weight: 700; color: var(--muted); text-align: right; white-space: nowrap; }
.sc-table th:first-child { text-align: left; }
.sc-table td { padding: 9px 3px; font-size: 12.5px; font-weight: 600; color: var(--text-2); text-align: right;
  border-top: 1px solid var(--line); white-space: nowrap; font-family: var(--font-num); }
.sc-table td:first-child { text-align: left; font-weight: 800; color: var(--text); font-family: inherit; }
.sc-table tr.is-main td { background: var(--blue-soft); font-weight: 800; color: var(--text); }
.sc-table tr.is-main td:first-child { border-radius: 8px 0 0 8px; }
.sc-table tr.is-main td:last-child { border-radius: 0 8px 8px 0; }
.sc-table .sc-basis { display: inline-block; margin-left: 4px; font-size: 10px; font-weight: 800; color: #fff;
  background: var(--blue); border-radius: 999px; padding: 1px 5px; vertical-align: 1px; }

.sc-concl { margin: 10px 0 0; padding: 14px 15px; border-radius: 16px; background: var(--text); color: #fff;
  font-size: 16.5px; font-weight: 800; line-height: 1.5; letter-spacing: -.2px; word-break: keep-all; }

.sc-notes { margin: 12px 0 0; padding-left: 17px; text-align: left; font-size: 12.5px; line-height: 1.62; color: var(--text-2); word-break: keep-all; }
.sc-notes li { margin: 0 0 3px; }

.sc-raw-wrap { margin-top: 12px; font-size: 12.5px; color: var(--muted); }
.sc-raw-wrap summary { font-weight: 800; cursor: pointer; text-align: left; }
.sc-raw-wrap pre { margin: 8px 0 0; padding: 10px 12px; max-height: 220px; overflow: auto; border-radius: 12px;
  background: var(--surface-2); font-size: 11.5px; line-height: 1.55; color: var(--text-2); white-space: pre-wrap; }

.sc-acts { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; }
@media (max-width: 360px) {
  .sc-field { grid-template-columns: 62px 1fr auto; }
  .sc-table td { font-size: 11.5px; padding: 8px 2px; }
}

.sc-sub { margin: 16px 0 6px; text-align: left; font-size: 12.5px; font-weight: 800; color: var(--muted); }

.sc-build { margin: 10px 0 0; text-align: center; font-size: 11px; color: #8a97a8; letter-spacing: .2px; }
.sc-build b { font-family: var(--font-num); font-weight: 800; color: #6b7a8d; }

/* =========================================================
   키패드 보조 줄 (메모리·함수) — 2026-11-30
   우리 팔레트: 짙은 남색·청록·금속 회색
   ========================================================= */
.keys-strip {
  display: grid;
  gap: 6px;
  padding: 0 10px;
  margin-bottom: 6px;
  flex: 0 0 auto;
}
.keys-strip--mem { grid-template-columns: repeat(5, 1fr) auto; }
.keys-strip--fn { grid-template-columns: repeat(5, 1fr); }
.key-chip {
  height: 40px;
  min-height: 40px;
  border: 1px solid #dbe3ee;
  border-radius: 13px;
  background: #eef1f5;
  color: var(--blue-deep);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: .2px;
  cursor: pointer;
  transition: transform .08s ease, background .12s ease;
}
.key-chip:active { transform: scale(.96); background: #e2e8f0; }
.key-chip[data-key="sqrt"], .key-chip[data-key="sq"] { color: var(--teal-deep); }
.mem-flag {
  align-self: center;
  padding: 0 8px;
  height: 24px;
  line-height: 24px;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal-deep);
  font-size: 11px;
  font-weight: 800;
}
.keypad .key-eq--wide {
  width: 100%;
  height: 100%;
  border-radius: 16px;
  background: var(--blue-deep);
  color: #fff;
  font-size: 26px;
  font-weight: 700;
  justify-self: stretch;
  align-self: stretch;
  box-shadow: 0 8px 18px rgba(10, 63, 150, .28);
}
.keypad .key-eq--wide:active { background: #082f70; }
.keypad .key-op {
  background: var(--teal-soft);
  color: var(--teal-deep);
  border-color: #cbe8f0;
  font-weight: 800;
}
.keypad .key-op:active { background: #d3eef6; }
.keypad .key-zero2, .keypad .key-zero3 { font-size: 19px; }
@media (max-height: 720px) {
  .key-chip { height: 34px; min-height: 34px; font-size: 13px; }
  .keys-strip { margin-bottom: 4px; }
}

/* =========================================================
   서랍(전체 메뉴) + 도구 계산기 — 2026-11-30
   ========================================================= */
.icon-btn--menu { margin-right: 2px; }
.drawer { position: fixed; inset: 0; z-index: 60; }
.drawer[hidden] { display: none; }
.drawer__scrim { position: absolute; inset: 0; background: rgba(8, 20, 36, .42); opacity: 0; transition: opacity .2s ease; }
.drawer.is-open .drawer__scrim { opacity: 1; }
.drawer__panel {
  position: absolute; left: 0; top: 0; bottom: 0; width: min(86vw, 340px);
  display: flex; flex-direction: column;
  background: #fbfcfe; border-radius: 0 26px 26px 0;
  box-shadow: 18px 0 48px rgba(10, 28, 48, .28);
  transform: translateX(-102%); transition: transform .24s cubic-bezier(.22, .8, .3, 1);
  overflow: hidden;
}
.drawer.is-open .drawer__panel { transform: translateX(0); }
.drawer__head {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 16px 16px;
  background: linear-gradient(160deg, #0f2740, #0a3f96 70%, #0c6f86);
  color: #fff;
}
.drawer__mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 12px; background: rgba(255,255,255,.16); }
.drawer__mark svg { width: 22px; height: 22px; stroke: #fff; stroke-width: 2.4; fill: none; stroke-linecap: round; }
.drawer__head strong { display: block; font-size: 15.5px; letter-spacing: -.3px; }
.drawer__head em { font-style: normal; font-size: 11px; opacity: .78; }
.drawer__head .sheet-close { margin-left: auto; color: #fff; }
.drawer__head .sheet-close svg { stroke: #fff; }
.drawer__list { flex: 1 1 auto; overflow-y: auto; padding: 8px 10px 24px; }
.drawer__sec {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 12px 10px 8px; border: 0; background: none;
  font-size: 11.5px; font-weight: 800; letter-spacing: .4px; color: #7d8b9c;
  cursor: pointer;
}
.drawer__sec i { font-style: normal; font-size: 10px; transition: transform .15s ease; }
.drawer__sec[aria-expanded="false"] i { transform: rotate(-90deg); }
.drawer__items { display: flex; flex-direction: column; gap: 2px; padding-bottom: 6px; }
.drawer__item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; min-height: 44px; padding: 0 12px;
  border: 0; border-radius: 13px; background: none;
  font-size: 14.5px; font-weight: 600; color: #1d2b3d; text-align: left; cursor: pointer;
}
.drawer__item::before {
  content: ""; width: 7px; height: 7px; border-radius: 3px; background: #c3cfdd; flex: 0 0 auto;
}
.drawer__item:active { background: #eef2f7; }
.drawer__item.is-current { background: #e8eef6; color: var(--blue-deep); font-weight: 800; }
.drawer__item.is-current::before { background: var(--teal); }

/* 도구 화면 */
.tool-body { padding-bottom: 28px; }
.tool-form { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.tool-field span { font-size: 12.5px; font-weight: 700; color: var(--text-2); }
.tool-input {
  width: 100%; min-height: 44px; padding: 0 12px;
  border: 1.5px solid var(--line); border-radius: 12px; background: #fff;
  font-size: 16px; color: var(--text); font-weight: 600;
}
textarea.tool-input { padding: 10px 12px; line-height: 1.5; resize: vertical; }
.tool-input:focus { outline: 2px solid var(--blue-soft); border-color: var(--blue); }
.tool-result { margin-top: 18px; }
.tool-result .result-main strong { font-size: 26px; }
.tool-need { margin: 0; padding: 14px; border-radius: 14px; background: #fff6e0; border: 1.5px solid #f0c65c; color: #7a4d00; font-size: 13.5px; font-weight: 800; line-height: 1.5; }
.tool-formula { margin: 12px 0 0; font-size: 12px; line-height: 1.6; color: var(--muted); word-break: break-all; }
.tool-note { margin: 8px 0 0; font-size: 12px; line-height: 1.6; color: var(--muted); }
.tool-swatch { height: 54px; margin-top: 10px; border-radius: 14px; border: 1px solid var(--line); }
.tool-switch {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  min-height: 48px; padding: 0 4px; border-bottom: 1px solid var(--line);
  font-size: 14px; font-weight: 700; color: var(--text-2);
}
.tool-switch input { width: 22px; height: 22px; accent-color: var(--blue); }
.tool-result .act-btn { margin-top: 14px; }

/* 테마 — 우리가 만든 4가지 (부산 바다·사상 새벽·경주 한옥) */
html[data-theme="dark"] {
  --bg: #10161d; --surface: #182129; --surface-2: #1e2933; --line: #2c3a47;
  --text: #eef3f8; --text-2: #c7d3e0; --muted: #9aa9b8;
  --blue-soft: #152a44; --green-soft: #10312a; --orange-soft: #3a2416; --teal-soft: #10323a;
}
html[data-theme="busan"] {
  --bg: #e6f2f8; --surface: #ffffff; --surface-2: #dcecf5; --line: #c3dcec;
  --text: #0a2333; --text-2: #1f3b4d; --muted: #4d6b7e;
  --blue: #0a5c8a; --blue-deep: #084a70; --blue-soft: #ddeef8;
  --teal: #0b7f8c; --teal-deep: #075f69; --teal-soft: #dcf3f5;
  --green: #0a7d52; --green-deep: #075f3f; --green-soft: #e0f5ec;
}
html[data-theme="sasang"] {
  --bg: #eef0f4; --surface: #ffffff; --surface-2: #e3e7ee; --line: #cfd6e0;
  --text: #101a2b; --text-2: #263449; --muted: #55657c;
  --blue: #1b3a63; --blue-deep: #102744; --blue-soft: #e2e8f2;
  --teal: #2b6f7f; --teal-deep: #1e5561; --teal-soft: #e0eff2;
  --green: #3d6b4f; --green-deep: #2b5039; --green-soft: #e4efe7;
}
html[data-theme="gyeongju"] {
  --bg: #f7f1e6; --surface: #fffdf8; --surface-2: #efe6d5; --line: #dfd2ba;
  --text: #2a2118; --text-2: #43362a; --muted: #6f5f4d;
  --blue: #6b4a2f; --blue-deep: #513623; --blue-soft: #f1e5d3;
  --teal: #7a6a3a; --teal-deep: #5c4f28; --teal-soft: #efe9d2;
  --green: #4f6b3a; --green-deep: #3a5029; --green-soft: #e9efdc;
}
