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

/* 계산기 — 산뜻한 민트 팔레트와 자체 아이콘으로 만든 독자 화면 */
:root {
  --bg: #eef7f2;
  --surface: #ffffff;
  --surface-2: #dff0e7;
  --line: #d9e7e0;
  --text: #10241d;
  --text-2: #2c443b;
  --muted: #78908a;
  --accent: #12a06a;
  --accent-press: #0d8757;
  --accent-soft: #e0f5ec;
  --red: #f0506e;
  --orange: #ff8a34;
  --radius-key: 22px;
  --shadow: 0 1px 2px rgba(16, 60, 45, .06), 0 8px 20px rgba(16, 60, 45, .07);
  --deep: #0b2f26;
  --deep-2: #12513f;
  --amber: #ffc247;
  --coral: #ff6b5e;
  --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: #eef7f2;
  background-image:
    radial-gradient(120% 62% at 8% 0%, #cdeee0 0%, rgba(205, 238, 224, 0) 62%),
    radial-gradient(110% 55% at 100% 0%, #ffe9c9 0%, rgba(255, 233, 201, 0) 58%),
    radial-gradient(100% 60% at 50% 108%, #d8f0e4 0%, rgba(216, 240, 228, 0) 60%);
  background-attachment: fixed;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic",
    "Noto Sans KR", "Segoe UI", Roboto, 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; }

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

/* ---------- 맨 위 이름표: 성일이의 계산기 ---------- */
.brandbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: calc(6px + env(safe-area-inset-top)) 12px 0;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #0e6b4d;
  user-select: none;
}
.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 { padding-top: calc(2px + env(safe-area-inset-top)); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 54px;
  padding: calc(4px + env(safe-area-inset-top)) 10px 4px;
  flex: 0 0 auto;
}
.topbar-right { display: flex; align-items: center; gap: 2px; }

.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: 118px;
  max-height: 34vh;
  margin: 2px 12px 12px;
  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 .copy-chip { background: rgba(255, 255, 255, .16); color: #eafaf3; padding: 7px 12px 7px 9px; }

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

.copy-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  padding: 4px 9px 4px 7px;
  border: 0;
  border-radius: 999px;
  background: var(--surface-2);
  color: #565d68;
  font-size: 11.5px;
  font-weight: 600;
  transition: background .15s ease, transform .08s ease;
}
.copy-chip svg { width: 13px; height: 13px; stroke-width: 1.9; }
.copy-chip:active { background: #dfe2e8; transform: scale(.95); }

.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 calc(18px + env(safe-area-inset-bottom));
  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; }

/* ---------- 스마트 계산 ---------- */
.smart-tabs { padding: 2px 12px 8px; }
.smart-tabs .life-tab {
  padding: 10px 2px;
  font-size: 13px;
  letter-spacing: -.4px;
  white-space: nowrap;
}

.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; }
.life-tab { display: inline-flex; align-items: center; gap: 2px; }
.brandbar__text { display: inline-flex; align-items: center; gap: 4px; }
.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: wrap;
  gap: 6px;
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px dashed var(--line);
}
.write-cands[hidden] { display: none; }
.wchip {
  max-width: 100%;
  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-cands-note {
  flex: 0 0 100%;
  margin: 0 0 2px;
  font-size: 12px;
  color: var(--muted);
}

.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-right { gap: 0; }
  .icon-btn { width: 38px; height: 38px; }
  .icon-btn svg { width: 20px; height: 20px; }
}

@media (max-width: 400px) {
  .icon-btn { width: 36px; height: 36px; }
  .icon-btn svg { width: 19px; height: 19px; }
  .write-tool { font-size: 12px; gap: 3px; }
  .write-tool svg { width: 15px; height: 15px; }
}
@media (max-width: 350px) {
  .icon-btn { width: 32px; height: 32px; }
  .icon-btn svg { width: 17px; height: 17px; }
  .write-tool { font-size: 11px; gap: 2px; padding: 0 3px; }
}
