:root { --navy: #1f3a6e; --upper: #7d4fd0; --lower: #1590b8; --val: #d62828; --input-bg: #eef3fb; }
body { background: #f3f5f9; }
.ig-intro { position: fixed; inset: 0; z-index: 80; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px; padding: 24px;
  background-color: #f6f8fc; background-image: linear-gradient(#dfe6f1 1px, transparent 1px), linear-gradient(90deg, #dfe6f1 1px, transparent 1px); background-size: 32px 32px; }
.ig-intro .card { background: #fff; border-radius: 28px; padding: 48px 56px; text-align: center; box-shadow: 0 12px 40px rgba(31,58,110,.16); max-width: 100%; }
.ig-intro h1 { margin: 0 0 32px; font-size: clamp(26px, 5vw, 46px); line-height: 1.35; color: var(--navy); letter-spacing: -.02em; }
.ig-intro .start { height: 54px; padding: 0 48px; border: 0; border-radius: 27px; background: var(--navy); color: #fff; font-size: 20px; font-weight: 800; }
.ig-intro .foot { color: #5b6577; font-size: 15px; text-align: center; }

.ig-app { display: flex; flex-direction: column; height: 100%; max-width: 1280px; margin: 0 auto; background: #fff; box-shadow: 0 0 0 1px var(--line); }
.ig-top { display: flex; align-items: center; gap: 8px; height: 54px; padding: 0 10px; background: var(--navy); color: #fff; flex: none; }
.ig-top h1 { flex: 1; text-align: center; font-size: clamp(15px, 2.2vw, 21px); margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ig-tools { display: flex; align-items: center; }
.ig-tools .vsep { width: 1px; height: 20px; background: rgba(255,255,255,.4); margin: 0 2px; }
.ig-ibtn { width: 40px; height: 40px; border: 0; border-radius: 8px; background: none; color: #fff; display: inline-flex; align-items: center; justify-content: center; }
.ig-ibtn:hover { background: rgba(255,255,255,.16); }
.ig-ibtn svg { width: 22px; height: 22px; }

.ig-main { flex: 1; min-height: 0; display: flex; }
.ig-col { display: flex; flex-direction: column; min-width: 0; }
.ig-col.left { width: 40%; border-right: 1px dashed #aab3c4; overflow: auto; }
.ig-col.right { flex: 1; }
.ig-input, .ig-slider { background: var(--input-bg); border-bottom: 2px solid var(--navy); }
.ig-input { padding: 16px 16px 14px; }
.ig-sentence { margin: 0; font-size: 18px; line-height: 2.5; }
.ig-sentence .ln { display: block; }
.ig-sentence .nb { white-space: nowrap; }
.ig-sentence .m, .ig-intline, .mf, .ig-pop-math, .nval { font-family: var(--math); }
.ig-sentence .m { font-size: 1.08em; }
.ig-sentence .brk { font-size: 1.25em; padding: 0 2px; }
.ig-confirm { text-align: right; margin-top: 6px; }
.ig-ok { height: 40px; padding: 0 30px; border: 0; border-radius: 20px; background: var(--navy); color: #fff; font-size: 18px; font-weight: 700; }
.ig-q { width: 20px; height: 20px; border-radius: 50%; border: 1px solid #9aa3b5; background: #fff; color: #8a93a6; font-size: 12px; font-weight: 700; line-height: 1; padding: 0; margin: 0 4px; vertical-align: middle; }
.ig-q.info { font-family: Georgia, serif; font-style: italic; }

/* 수식 입력 칸 */
.mf { display: inline-flex; align-items: center; min-width: 54px; min-height: 34px; padding: 1px 8px; border: 1.5px solid #8793ab; border-radius: 6px; background: #fff; vertical-align: middle; cursor: text; font-size: 20px; line-height: 1.2; outline: none; }
.mf.wide { min-width: 150px; }
.mf.focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,201,.2); }
.hinting .mf.empty { animation: igblink 1.1s ease-in-out infinite; }
@keyframes igblink { 50% { background: #ffe7a8; border-color: #e0a100; } }
.mf-row { display: inline-flex; align-items: center; min-height: 1.1em; white-space: nowrap; }
.mf-hole { min-width: .7em; min-height: .9em; border: 1px dashed #8793ab; border-radius: 2px; }
.mf-c.it { font-style: italic; }
.mf-c.op { padding: 0 .2em; }
.mf-c.fn-s { margin-left: .12em; }
.mf-c.fn-e { margin-right: .12em; }
.mf-sup { font-size: .68em; align-self: flex-start; margin-top: -.25em; display: inline-flex; }
.mf-sub { font-size: .68em; align-self: flex-end; margin-bottom: -.25em; display: inline-flex; }
.mf-log { display: inline-flex; align-items: center; margin-right: .1em; }
.mf-frac { display: inline-flex; flex-direction: column; align-items: center; margin: 0 .15em; font-size: .9em; }
.mf-num { border-bottom: 1.5px solid currentColor; padding: 0 .2em 1px; display: flex; justify-content: center; align-self: stretch; }
.mf-den { padding: 1px .2em 0; display: flex; justify-content: center; }
.mf-sqrt { display: inline-flex; align-items: stretch; margin: 0 .1em; }
.mf-rad { font-size: 1.15em; line-height: 1; align-self: center; transform: scaleY(1.1); }
.mf-radbody { border-top: 1.5px solid currentColor; padding: 1px .15em 0 .1em; margin-top: .1em; display: inline-flex; }
.mf-caret { display: inline-block; width: 2px; height: 1.1em; background: var(--primary); margin: 0 -1px; animation: igcaret 1s steps(1) infinite; }
@keyframes igcaret { 50% { opacity: 0; } }
.mf-paren { display: inline-flex; align-items: center; }
.mf-paren::before { content: "("; } .mf-paren::after { content: ")"; }
.mf-paren.tall { padding: 2px 8px; border-left: 1.5px solid currentColor; border-right: 1.5px solid currentColor; border-radius: 10px / 50%; margin: 0 3px; }
.mf-paren.tall::before, .mf-paren.tall::after { content: none; }

.ig-box { margin: 14px 16px 0; border: 1px solid #b9c2d3; border-radius: 10px; overflow: hidden; }
.ig-box + .ig-box { border-top-style: dashed; }
.ig-box h2 { margin: 0; padding: 8px; text-align: center; font-size: 18px; background: #e3e9f3; color: #25324a; }
.ig-sumrow { display: flex; align-items: center; padding: 12px 14px; font-size: 18px; min-height: 52px; }
.ig-sumrow + .ig-sumrow { border-top: 1px solid #dde2ec; }
.ig-sumrow label { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; cursor: pointer; }
.ig-sumrow input { width: 20px; height: 20px; accent-color: var(--navy); }
.ig-sumrow.upper .lab { color: var(--upper); } .ig-sumrow.lower .lab { color: var(--lower); }
.ig-sumrow .colon { margin: 0 10px 0 4px; }
.val { color: var(--val); font-weight: 800; font-family: var(--math); font-size: 1.1em; }
.ig-intline { display: flex; align-items: center; flex-wrap: nowrap; gap: 4px; padding: 14px; font-size: 21px; min-height: 76px; overflow-x: auto; white-space: nowrap; }
.ig-int { display: inline-flex; align-items: center; }
.ig-int .sym { font-size: 2.1em; line-height: 1; transform: scaleX(.8); font-style: normal; }
.ig-int .lim { display: inline-flex; flex-direction: column; justify-content: space-between; align-self: stretch; font-size: .68em; margin-left: -2px; margin-right: 4px; padding: 2px 0; }
.ig-int .lim > span { display: inline-flex; min-height: 1em; }
.ig-intline .dx { font-style: italic; margin-left: 3px; letter-spacing: -.02em; }
.ig-intline .sq { display: inline-block; width: .8em; height: .8em; border: 1.5px solid #8793ab; border-radius: 2px; }
.ig-intline .lim .sq { width: .9em; height: .9em; }
.ig-intline .eq { margin: 0 6px; color: #000; }
.ig-ktoggle { margin: 14px 16px 12px; align-self: flex-start; height: 34px; padding: 0 12px; border: 1px solid #b9c2d3; border-radius: 8px; background: #eef1f6; color: #4a556b; display: inline-flex; align-items: center; gap: 6px; }
.ig-ktoggle svg { width: 22px; height: 22px; }

.ig-slider { display: flex; align-items: stretch; }
.ig-slider .play { width: 48px; border: 0; background: #dbe4f3; color: var(--navy); display: flex; align-items: center; justify-content: center; }
.ig-slider .play svg { width: 20px; height: 20px; }
.ig-slider .track { flex: 1; padding: 6px 16px 8px; min-width: 0; }
.ig-slider .nval { font-size: 18px; text-align: center; font-weight: 700; }
.ig-slider .range { display: flex; align-items: center; gap: 10px; font-size: 14px; color: #4a556b; }
.ig-slider input[type=range] { flex: 1; accent-color: var(--navy); min-width: 0; }
.ig-graph { flex: 1; min-height: 0; position: relative; }
.ig-graph canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.ig-graph canvas.grabbing { cursor: grabbing; }
.ig-zoom { position: absolute; right: 10px; bottom: 10px; display: flex; flex-direction: column; gap: 4px; }
.ig-zoom button { width: 36px; height: 36px; border: 1px solid #b9c2d3; border-radius: 8px; background: rgba(255,255,255,.94); color: #2a3347; font-size: 20px; line-height: 1; padding: 0; }
.ig-zoom button:hover { border-color: var(--navy); }

/* 키패드 */
.ig-keypad { flex: none; background: #e6eaf1; border-top: 1px solid #c3cbd9; padding: 8px 12px 10px; }
.ig-keypad.hide { display: none; }
.ig-kcols { display: grid; grid-template-columns: 3fr 4fr 3fr; gap: 14px; max-width: 860px; margin: 0 auto; }
.ig-kcol { display: grid; gap: 5px; grid-auto-rows: 42px; }
.ig-kcol.c1, .ig-kcol.c3 { grid-template-columns: repeat(3, 1fr); }
.ig-kcol.c2 { grid-template-columns: repeat(4, 1fr); }
.ig-key { border: 0; border-radius: 8px; background: #f4f6fa; color: #2a3347; font: 19px var(--math); display: flex; align-items: center; justify-content: center; user-select: none; touch-action: manipulation; padding: 0; }
.ig-key:active { transform: translateY(1px); filter: brightness(.95); }
.ig-key.num { background: #fff; border: 1px solid #b3bccd; font-size: 22px; font-weight: 600; }
.ig-key.op { background: #46546f; color: #fff; font-size: 22px; }
.ig-key.enter { background: var(--primary); color: #fff; font: 700 17px var(--ui); }
.ig-key.txt { font: 700 15px var(--ui); }
.ig-key.w2 { grid-column: span 2; } .ig-key.w3 { grid-column: span 3; }
.ig-key .box { display: inline-block; width: .6em; height: .75em; border: 1.5px solid currentColor; border-radius: 1px; }
.ig-key sup .box, .ig-key sub .box { width: .55em; height: .55em; }
.ig-key .kfrac { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; }
.ig-key .kfrac .box { width: .55em; height: .5em; }
.ig-key .kfrac hr { width: 1em; border: 0; border-top: 1.5px solid currentColor; margin: 0; }
.ig-key .ksqrt { display: inline-flex; align-items: flex-end; }
.ig-key .ksqrt .box { border-width: 1.5px 1.5px 1.5px 1.5px; box-shadow: 0 -3px 0 -1.5px currentColor; margin-top: 3px; }
.ig-key .ksqrt .bar { border-top: 1.5px solid currentColor; padding-top: 2px; display: inline-flex; }
.ig-void { visibility: hidden; }
.ig-logo { grid-column: span 3; display: flex; align-items: center; justify-content: center; color: #9aa4b6; opacity: .6; font: 800 15px var(--ui); letter-spacing: .08em; cursor: default; user-select: none; }

/* 팝업 내용 */
.ig-slides { width: min(520px, 78vw); }
.ig-slide { min-height: 250px; line-height: 1.9; font-size: 16.5px; }
.ig-slide h3 { margin: 0 0 10px; font-size: 17px; color: var(--navy); }
.ig-slide p { margin: 0 0 6px; }
.ig-slide .ind { padding-left: 2em; }
.ig-slide .hl { background: #eef3fb; border: 1px solid #c6d3ea; border-radius: 10px; padding: 10px 14px; margin: 8px 0; text-align: center; }
.ig-slide .with-fig { display: flex; gap: 12px; align-items: flex-start; }
.ig-slide .with-fig > div { flex: 1; min-width: 0; }
.ig-slide .with-fig > svg { flex: 0 0 46%; max-width: 46%; margin: 0 !important; }
@media (max-width: 560px) { .ig-slide .with-fig { display: block; } .ig-slide .with-fig > svg { max-width: 100%; margin: 6px auto 0 !important; } }
.ig-slide .note { border: 1px dashed #aab3c4; border-radius: 8px; padding: 6px 12px; margin-top: 8px; display: inline-block; }
.ig-nav { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 10px; }
.ig-nav button { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: #fff; font-size: 18px; }
.ig-nav .dots { display: flex; gap: 6px; }
.ig-nav .dots i { width: 8px; height: 8px; border-radius: 50%; background: #cdd4e0; }
.ig-nav .dots i.on { background: var(--navy); }
.ig-pop-math { font-size: 1.08em; white-space: nowrap; }
.ig-pop-math i { font-style: italic; }
.pm-frac { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; font-size: .9em; line-height: 1.2; margin: 0 2px; }
.pm-frac > span:first-child { border-bottom: 1.5px solid currentColor; padding: 0 4px; }
.pm-stack { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; line-height: 1.05; margin: 0 3px; }
.pm-stack .s { font-size: .62em; }
.pm-stack .big { font-size: 1.5em; line-height: 1; }
.pm-int { display: inline-flex; align-items: center; vertical-align: middle; }
.pm-int .sym { font-size: 1.9em; line-height: 1; transform: scaleX(.8); }
.pm-int .lim { display: inline-flex; flex-direction: column; justify-content: space-between; align-self: stretch; font-size: .62em; margin: 0 3px 0 -2px; line-height: 1.1; }
.ig-slide sub, .ig-slide sup, .ig-fnbox sub, .ig-fnbox sup { font-size: .62em; }
.ig-fn { width: min(560px, 80vw); line-height: 1.800; }
.ig-fnbox { border: 1px solid #c6d3ea; background: #f7f9fd; border-radius: 10px; padding: 8px 16px; margin: 8px 0; }
.ig-fnbox div { padding: 2px 0; }
.ig-fnbox .mid { text-align: left; padding-left: 3.2em; line-height: 1; }
.ig-how { display: grid; grid-template-columns: 2fr 3fr; grid-template-rows: auto 1fr; gap: 4px; height: 150px; margin-top: 10px; border: 1px solid #c3cbd9; border-radius: 8px; padding: 6px; background: #fafbfd; font-size: 11px; color: #6b7486; }
.ig-how > div { border: 1px solid #d5dbe6; border-radius: 5px; padding: 4px 6px; background: #fff; display: flex; flex-direction: column; gap: 3px; }
.ig-how .on { outline: 3px solid var(--val); outline-offset: -1px; }
.ig-how .mini { border: 1px solid #b9c2d3; border-radius: 3px; padding: 1px 5px; align-self: flex-start; }
.ig-how .mini.r { align-self: flex-end; }

@media (max-width: 760px), (orientation: portrait) and (max-width: 900px) {
  .ig-main { flex-direction: column; overflow: auto; }
  .ig-col { display: contents; }
  .ig-col > * { flex: none; }
  .ig-col.left { width: auto; }
  #secInput { order: 1; } #secSlider { order: 2; } #secGraph { order: 3; flex: none; height: 62vw; min-height: 260px; border-bottom: 1px dashed #aab3c4; }
  #secSum { order: 4; } #secInt { order: 5; } #btnKeypad { order: 6; }
  .ig-sentence { font-size: 16px; line-height: 2.4; }
  .mf { font-size: 17px; min-height: 30px; }
  .mf.wide { min-width: 110px; }
  .ig-kcols { grid-template-columns: 3fr 4fr; gap: 8px; }
  .ig-kcol.c3 { grid-column: 1 / -1; grid-template-columns: repeat(6, 1fr); grid-template-areas: 'clear clear back . up .' 'enter enter enter left down right'; }
  .ig-kcol.c3 .ig-void { display: none; }
  .ig-kcol.c3 .ka-clear { grid-area: clear; } .ig-kcol.c3 .ka-back { grid-area: back; } .ig-kcol.c3 .ka-up { grid-area: up; } .ig-kcol.c3 .ka-left { grid-area: left; } .ig-kcol.c3 .ka-down { grid-area: down; } .ig-kcol.c3 .ka-right { grid-area: right; } .ig-kcol.c3 .ka-enter { grid-area: enter; }
  .ig-kcol { grid-auto-rows: 38px; }
  .ig-logo { display: none; }
}

.ig-logo img { height: 16px; display: block; filter: grayscale(1); }
