/* 잇담 — 휴대폰 앱 모양
   스타일: editorial-greeting (흰 바탕 + 한 겹 톤 판, 큰 둥근 판 22 / 버튼 알약 모양)
   얼굴: 판 색을 약봉투 세상의 옅은 세이지(#EFF4F1)로, 서명 요소는 조제약 봉투(톱니 윗변) 그림 한 곳 */
:root {
  color-scheme: light;
  --ground: #FFFFFF;
  --panel: #EFF4F1;
  --panel-press: #E3EBE7;
  --line: #E1E8E4;
  --control: #B9C4C0;
  --ink: #17201D;
  --ink-2: #4A5651;
  --accent: #0B6B5D;
  --accent-press: #08564B;
  --accent-soft: #D9EDE7;
  --warn: #8A4200;
  --warn-soft: #FFF1DC;
  --warn-line: #E9B572;
  --danger: #B3261E;
  --r-card: 22px;
  --r-inner: 14px;
  --gutter: 16px;
  --tap: 52px;
  --bar: 56px;
  --tabbar: 64px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --top: env(safe-area-inset-top, 0px);
  --bottom: env(safe-area-inset-bottom, 0px);
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", sans-serif;
  font-size: 18px;
  line-height: 1.55;
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html { background: var(--ground); }
body { margin: 0; background: var(--ground); word-break: keep-all; overflow-wrap: anywhere; overscroll-behavior-y: none; -webkit-tap-highlight-color: transparent; }
h1, h2, p { margin: 0; }
a { color: var(--accent); }
img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.tap { cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none; transition: transform .12s var(--ease), background-color .12s, opacity .12s; }

/* ---------- 앱 틀: 위 막대 · 본문 · 아래 탭 ---------- */
.appbar { position: fixed; inset: 0 0 auto; z-index: 20; background: var(--ground); padding-top: var(--top); transition: box-shadow .2s; }
body.scrolled .appbar { box-shadow: 0 1px 0 var(--line); }
.appbar-in { max-width: 560px; margin: 0 auto; height: var(--bar); display: flex; align-items: center; gap: 4px; padding-inline: 8px var(--gutter); }
.appbar h1 { font-size: 20px; font-weight: 700; line-height: 1.2; padding-left: 8px; outline: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back { width: 48px; height: 48px; border: 0; background: none; border-radius: 999px; display: grid; place-items: center; color: var(--ink); margin-right: -6px; }
.back svg { width: 28px; height: 28px; stroke-width: 2.2; }
.back:active { background: var(--panel); }

main { max-width: 560px; margin: 0 auto; padding: calc(var(--bar) + var(--top) + 8px) var(--gutter) calc(var(--tabbar) + var(--bottom) + 32px); outline: none; }
body.has-action main { padding-bottom: calc(var(--tap) + 32px + var(--bottom) + 24px); }

.tabbar { position: fixed; inset: auto 0 0; z-index: 20; background: var(--ground); box-shadow: 0 -1px 0 var(--line); padding-bottom: var(--bottom); }
body.has-action .tabbar { display: none; }
.tabbar-in { max-width: 560px; margin: 0 auto; height: var(--tabbar); display: grid; grid-template-columns: repeat(4, 1fr); }
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--ink-2); text-decoration: none; font-size: 13px; font-weight: 600; min-height: 48px; }
.tab svg { width: 26px; height: 26px; }
.tab[aria-current="page"] { color: var(--accent); }
.tab[aria-current="page"] svg { stroke-width: 2.2; }
.tab:active { opacity: .6; }
/* 가운데 찍기 탭: 이 앱의 주된 일 */
.tab-shoot i { display: grid; place-items: center; }

.actionbar { position: fixed; inset: auto 0 0; z-index: 20; background: var(--ground); box-shadow: 0 -1px 0 var(--line); padding: 12px var(--gutter) calc(12px + var(--bottom)); }
.actionbar-in { max-width: 528px; margin: 0 auto; display: grid; }

/* 화면 전환: 깊이 들어가면 오른쪽에서, 돌아오면 왼쪽에서, 탭끼리는 살짝 */
section.anim[data-anim="push"] { animation: push .24s var(--ease); }
section.anim[data-anim="pop"] { animation: pop .24s var(--ease); }
section.anim[data-anim="fade"] { animation: fade .2s ease-out; }
@keyframes push { from { transform: translateX(28%); opacity: 0; } }
@keyframes pop { from { transform: translateX(-20%); opacity: 0; } }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }

/* ---------- 버튼: 진한 버튼 하나 + 글자 버튼 하나, 이 두 가지만 ---------- */
.btn { appearance: none; border: 0; font-weight: 700; font-size: 19px; min-height: 56px; padding: 12px 22px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; background: none; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:active { background: var(--accent-press); }
.btn-text { color: var(--accent); font-weight: 600; min-height: 52px; }
.btn-text:active { background: var(--panel); }
.btn-text.danger { color: var(--danger); }
.btn-wide { width: 100%; }

/* ---------- 공통 글 ---------- */
.date { color: var(--ink-2); font-size: 17px; font-weight: 600; }
.headline { font-size: 28px; line-height: 1.3; font-weight: 700; letter-spacing: -0.01em; margin-top: 4px; }
.headline b { color: var(--accent); font-weight: 700; }
.sub { color: var(--ink-2); margin-top: 6px; }
.lead { color: var(--ink-2); }
.fine { color: var(--ink-2); font-size: 15px; margin-top: 24px; }
.group { font-size: 16px; font-weight: 700; color: var(--ink-2); margin: 28px 0 4px; }
.group:first-child { margin-top: 8px; }
.group .num { font-weight: 400; margin-left: 4px; }
.chev { width: 20px; height: 20px; color: var(--ink-2); margin-left: auto; flex: none; }
.line-link { display: flex; align-items: center; gap: 8px; min-height: 56px; margin-top: 16px; color: var(--accent); font-weight: 600; text-decoration: none; }
.line-link .chev { color: var(--accent); }


/* ---------- 원: 찍기 버튼에서 가져온 이 앱의 모양 ---------- */
.ring { position: relative; display: inline-grid; place-items: center; width: var(--s, 46px); height: var(--s, 46px); flex: none; }
.ring > svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); stroke-width: 7; stroke-linecap: butt; }
.ring circle { fill: none; stroke: var(--line); }
.ring .val, .ring .seg.done { stroke: var(--accent); }
.ring .seg.sel { stroke: var(--accent); opacity: .28; }
.ring .seg.miss { stroke: var(--warn-line); }
.ring .in { position: relative; display: grid; justify-items: center; text-align: center; line-height: 1.15; }
.ring .in b { font-size: 14px; font-weight: 700; letter-spacing: -0.02em; }
.ring .in > svg { width: 20px; height: 20px; color: var(--accent); stroke-width: 2.6; }
.ring.big { --s: 236px; display: grid; margin: 0 auto; }
.ring.big > svg { stroke-width: 4.5; }
.ring.big .in { gap: 4px; }
.ring.big .in small { color: var(--accent); font-size: 16px; font-weight: 700; }
.ring.big .in b { font-size: 40px; letter-spacing: -0.02em; }
.ring.big .in span { color: var(--ink-2); font-size: 17px; }
.ring.big .in svg { width: 44px; height: 44px; color: var(--accent); stroke-width: 2.6; }

/* ---------- 오늘: 큰 원 하나 + 그 때 약 + 버튼 하나 ---------- */
.today { padding-top: 8px; }
.hero { margin-top: 28px; text-align: center; display: grid; justify-items: center; }
.pills { list-style: none; margin: 20px 0 18px; padding: 0; width: 100%; }
.pills a { display: flex; justify-content: center; align-items: baseline; gap: 8px; min-height: 44px; padding: 6px 0; color: var(--ink); text-decoration: none; border-radius: 10px; }
.pills a:active { opacity: .6; }
.pills .nm { font-weight: 600; line-height: 1.35; }
.pills .dose { color: var(--ink-2); white-space: nowrap; }

/* 하루의 때: 원 칸과 같은 순서의 작은 원들 */
.slots { list-style: none; margin: 32px 0 0; padding: 0; display: grid; grid-template-columns: repeat(var(--n), 1fr); }
.slots button { width: 100%; border: 0; background: none; display: grid; justify-items: center; gap: 4px; padding: 8px 0; font: inherit; color: var(--ink); cursor: pointer; }
.slots i { width: 34px; height: 34px; border-radius: 999px; box-shadow: inset 0 0 0 2px var(--line); display: grid; place-items: center; } /* taste-skill-ignore: 때 표시 원 */
.slots i svg { width: 20px; height: 20px; stroke-width: 2.6; }
.slots .done i { background: var(--accent); color: #fff; box-shadow: none; }
.slots .miss i { box-shadow: inset 0 0 0 2px var(--warn-line); }
.slots [aria-current] i { box-shadow: inset 0 0 0 3px var(--accent); }
.slots .done[aria-current] i { box-shadow: 0 0 0 3px var(--accent-soft); }
.slots b { font-size: 16px; }
.slots span { color: var(--ink-2); font-size: 14px; }
.slots button:active { opacity: .6; }

/* 첫 화면 */
.first { padding: 8px 4px 0; }
.first .headline { margin-top: 6px; }
.env-demo { margin: 28px 0 24px; padding: 20px 0 0; }
.env-demo figcaption { color: var(--ink-2); font-size: 16px; margin-top: 12px; text-align: center; }
.first .fine { text-align: center; margin-top: 14px; }

/* 조제약 봉투 그림: 톱니 윗변이 이 앱의 표시 */
.env { position: relative; max-width: 320px; margin: 0 auto; padding-top: 10px; transform: rotate(-2deg); }
.env-paper { position: relative; background: #fff; border-radius: 0 0 12px 12px; padding: 16px 16px 14px; font-size: 15px; color: var(--ink-2); box-shadow: 0 1px 2px rgba(23, 32, 29, .08), 0 6px 18px rgba(23, 32, 29, .06); }
.env-paper::before { content: ""; position: absolute; left: 0; right: 0; top: -10px; height: 10px; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='10'%3E%3Cpath d='M0 10L8 0l8 10z' fill='%23fff'/%3E%3C/svg%3E") repeat-x; }
.env-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.env-top b { color: var(--ink); font-size: 17px; }
.env-top span { font-size: 13px; }
.env-row { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; padding-block: 6px; align-items: center; }
.env-row + .env-row { border-top: 1px solid var(--line); } /* taste-skill-ignore: 봉투 안 줄 */
.env-row mark { background: none; color: var(--ink); font-weight: 700; }

/* ---------- 찍기 · 읽는 중 ---------- */
.shoot { padding-top: 8px; }
.shoot .lead { text-align: center; font-size: 17px; }
.viewfinder { position: relative; margin: 16px 0 0; border-radius: var(--r-card); aspect-ratio: 4 / 3; display: grid; place-items: center; padding: 28px 24px; overflow: hidden; }
.viewfinder .env { width: 86%; }
.viewfinder .env-paper { font-size: 13px; padding: 12px; }
.viewfinder .env-top b { font-size: 15px; }
.viewfinder img { max-height: 100%; width: auto; border-radius: 8px; }
.corner { position: absolute; width: 28px; height: 28px; border: 0 solid var(--accent); }
.corner.tl { top: 14px; left: 14px; border-width: 3px 0 0 3px; border-top-left-radius: 10px; }
.corner.tr { top: 14px; right: 14px; border-width: 3px 3px 0 0; border-top-right-radius: 10px; }
.corner.bl { bottom: 14px; left: 14px; border-width: 0 0 3px 3px; border-bottom-left-radius: 10px; }
.corner.br { bottom: 14px; right: 14px; border-width: 0 3px 3px 0; border-bottom-right-radius: 10px; }
.tips { list-style: none; margin: 16px 0 0; padding: 0 4px; display: grid; gap: 4px; }
.tips li { display: flex; align-items: center; gap: 12px; min-height: 36px; color: var(--ink-2); font-size: 16px; }
.tips svg { color: var(--accent); }
.tips b { color: var(--ink); font-weight: 600; margin-right: 4px; }
.shoot .resume { margin-top: 16px; }
.shutter-row { position: relative; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; margin-top: 18px; }
.shutter { grid-column: 2; width: 84px; height: 84px; border-radius: 999px; border: 4px solid var(--accent); background: var(--ground); display: grid; place-items: center; padding: 0; }
.shutter i { width: 62px; height: 62px; border-radius: 999px; background: var(--accent); transition: transform .12s var(--ease); }
.shutter:active i { transform: scale(.88); background: var(--accent-press); }
.shutter-label { grid-column: 2; grid-row: 2; text-align: center; font-weight: 700; font-size: 17px; margin-top: 6px; }
.album { grid-column: 1; grid-row: 1; justify-self: center; border: 1.5px solid var(--line); background: var(--ground); border-radius: 18px; width: 64px; height: 64px; display: grid; place-items: center; align-content: center; gap: 0; font-size: 13px; font-weight: 600; color: var(--ink); }
.album:active { background: var(--panel-press); transform: scale(.95); }

.scanline { position: absolute; left: 6%; right: 6%; top: 10%; height: 3px; border-radius: 3px; background: var(--accent); animation: scan 1.8s ease-in-out infinite alternate; }
@keyframes scan { to { top: 88%; } }
.scanning img, .scanning .env { opacity: .8; }
.steps { list-style: none; margin: 22px 0 0; padding: 0 4px; display: grid; gap: 14px; }
.steps li { display: flex; align-items: center; gap: 12px; color: var(--ink-2); }
.steps i { width: 28px; height: 28px; border-radius: 999px; box-shadow: inset 0 0 0 2px var(--control); display: grid; place-items: center; flex: none; } /* taste-skill-ignore: 단계 원 */
.steps i svg { width: 18px; height: 18px; stroke-width: 2.8; }
.steps .done { color: var(--ink); }
.steps .done i { background: var(--accent); color: #fff; box-shadow: none; }
.steps .now { color: var(--ink); font-weight: 700; }
.steps .now i { box-shadow: inset 0 0 0 3px var(--accent-soft); border-top: 3px solid var(--accent); animation: spin .9s linear infinite; } /* taste-skill-ignore: 도는 원 */
@keyframes spin { to { transform: rotate(360deg); } }
.err { margin-top: 20px; color: var(--warn); }
.err p { color: var(--ink); margin-top: 4px; }

/* ---------- 목록 한 가지 모양 (확인·약 목록·설정) ---------- */
.review, .detail, .settings, .form { padding-top: 8px; }
.src { color: var(--ink-2); font-size: 16px; margin-top: 4px; }
.list { list-style: none; margin: 16px 0 0; padding: 0; }
.list > li { border-bottom: 1px solid var(--line); }
.list > li > a, .list > li > button, .list summary { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 72px; padding: 12px 0; border: 0; background: none; color: var(--ink); text-decoration: none; text-align: left; font: inherit; cursor: pointer; }
.list > li > a:active, .list > li > button:active, .list summary:active { opacity: .6; }
.list .txt { flex: 1; min-width: 0; display: grid; gap: 2px; }
.list .nm { font-weight: 700; line-height: 1.35; }
.list .meta { color: var(--ink-2); font-size: 16px; }
.list.done .nm { color: var(--ink-2); }
/* 줄 오른쪽 끝 체크 */
.list > li.has-chk { display: flex; align-items: center; gap: 4px; }
.list > li.has-chk > a, .list > li.has-chk > button:first-child { flex: 1; min-width: 0; }
.list .chk { flex: none; width: 48px; height: 48px; margin-right: -6px; border: 0; background: none; padding: 0; display: grid; place-items: center; color: var(--control); cursor: pointer; }
.list .chk svg { width: 34px; height: 34px; padding: 7px; border-radius: 999px; box-shadow: inset 0 0 0 2px var(--line); stroke-width: 2.8; } /* taste-skill-ignore: 체크 원 */
.list .chk[aria-pressed="true"] { color: #fff; }
.list .chk[aria-pressed="true"] svg { background: var(--accent); box-shadow: none; }
.list .chk:active svg { transform: scale(.9); }
.need { font-style: normal; color: var(--warn); font-weight: 700; }
.status { font-size: 15px; font-weight: 600; }
.status.ok { color: var(--accent); }
.status.warn { color: var(--warn); }
.review > .btn-text { margin-top: 8px; padding-inline: 0; }
.none { color: var(--ink-2); padding: 12px 0; }
.empty { padding-top: 24px; display: grid; gap: 6px; }
.empty .btn { margin-top: 20px; }

/* 약 정보: 남은 날 큰 원 + 이름 + 이름표:값 줄 */
.med-hero { display: grid; justify-items: center; gap: 16px; padding: 12px 0 8px; text-align: center; }
.med-hero .ring.big { --s: 180px; }
.med-hero .ring.big .in b { font-size: 48px; }
.full { font-size: 17px; color: var(--ink-2); }
.kvs { list-style: none; margin: 12px 0 20px; padding: 0; }
.kvs li { display: flex; justify-content: space-between; align-items: center; gap: 16px; min-height: 56px; border-bottom: 1px solid var(--line); }
.kvs span { color: var(--ink-2); }
.kvs b { font-weight: 600; text-align: right; }
.detail .btn + .btn { margin-top: 4px; }

/* 설정 */
.settings .kvs { margin-bottom: 8px; }
.note { color: var(--ink-2); font-size: 16px; }
.settings .list { margin-top: 20px; }
.settings .list summary::-webkit-details-marker { display: none; }
.settings details[open] summary .chev { transform: rotate(90deg); }
.settings details p { padding: 0 0 12px; color: var(--ink-2); font-size: 16px; }
.settings details p b { color: var(--ink); margin-right: 6px; }
.settings > .btn-text { margin-top: 24px; }

/* ---------- 약 입력칸 (시트·고치기 화면) ---------- */
.drug .label { display: block; font-size: 16px; font-weight: 600; color: var(--ink-2); }
.drug .name { display: grid; gap: 8px; }
.drug textarea, .drug select, .drug input[type=date] { font: inherit; color: var(--ink); width: 100%; min-height: 52px; padding: 10px 14px; border-radius: var(--r-inner); border: 1.5px solid var(--line); background: var(--ground); }
.drug textarea { font-size: 19px; font-weight: 700; line-height: 1.35; resize: none; display: block; field-sizing: content; min-height: 0; }
.drug select { appearance: none; background: var(--ground) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' fill='none' stroke='%234A5651' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M5 8l5 5 5-5'/%3E%3C/svg%3E") no-repeat right 14px center; padding-right: 40px; }
.drug textarea:focus, .drug select:focus, .drug input:focus { outline: none; border-color: var(--accent); }
.drug .missing textarea, .drug select.missing, .stepper.missing { border-color: var(--warn-line); }
.raw { font-size: 15px; color: var(--ink-2); margin-top: 6px; }
.row { display: grid; gap: 8px; margin-top: 18px; }
.dose-ctl { display: flex; gap: 10px; align-items: center; }
.stepper { display: inline-flex; align-items: center; justify-self: start; border-radius: 999px; border: 1.5px solid var(--line); height: 52px; background: var(--ground); }
.stepper button { width: 48px; height: 48px; border: 0; background: none; border-radius: 999px; display: grid; place-items: center; color: var(--accent); }
.stepper button:active { background: var(--panel); }
.stepper input { width: 44px; border: 0; background: none; text-align: center; font: inherit; font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); padding: 0; }
.stepper input:focus { outline: none; }
.stepper input::placeholder { color: var(--warn); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; background: none; border-radius: 999px; padding: 3px; min-width: 0; border: 1.5px solid transparent; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; width: 100%; height: 100%; cursor: pointer; }
.seg span { display: grid; place-items: center; min-height: 44px; border-radius: 999px; font-weight: 600; font-size: 16px; color: var(--ink-2); padding-inline: 4px; white-space: nowrap; }
.seg input:checked + span { background: var(--accent); color: #fff; }
.seg input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 1px; }
.seg.missing { border-color: var(--warn-line); }
.seg-sm { flex: 1; min-width: 0; }
.form .btn-text { margin-top: 24px; }

/* 고치기 시트 */
.edit { border: 0; padding: 0; margin: auto 0 0; width: 100%; max-width: 100%; max-height: 92vh; background: transparent; }
.edit::backdrop { background: rgba(23, 32, 29, .45); }
.edit-in { max-width: 560px; margin: 0 auto; background: var(--ground); border-radius: 22px 22px 0 0; padding: 8px var(--gutter) calc(12px + var(--bottom)); max-height: 92vh; overflow-y: auto; overscroll-behavior: contain; }
.edit[open] .edit-in { animation: sheet .24s var(--ease); }
.grab { width: 40px; height: 5px; border-radius: 999px; background: var(--line); margin: 0 auto 12px; }
.edit h2 { font-size: 20px; margin-bottom: 12px; }
.edit .btn-primary { margin-top: 24px; }

/* 확인 시트 */
.sheet { border: 0; padding: 0; margin: auto 0 0; width: 100%; max-width: 100%; background: transparent; }
.sheet::backdrop { background: rgba(23, 32, 29, .45); }
.sheet form { max-width: 560px; margin: 0 auto; background: var(--ground); border-radius: 22px 22px 0 0; padding: 24px var(--gutter) calc(16px + var(--bottom)); display: grid; gap: 10px; }
.sheet p { font-size: 19px; font-weight: 600; margin-bottom: 6px; }
.sheet .btn { width: 100%; }
.sheet[open] form { animation: sheet .24s var(--ease); }
@keyframes sheet { from { transform: translateY(100%); } }

.toast { position: fixed; left: 50%; bottom: calc(var(--tabbar) + var(--bottom) + 16px); transform: translate(-50%, 12px); z-index: 30; background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 999px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100% - 32px); font-size: 17px; }
body.has-action .toast { bottom: calc(var(--tap) + 40px + var(--bottom)); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (hover: hover) {
  .pills a:hover, .rows > li > a:hover { background: var(--panel-press); }
  .btn-primary:hover { background: var(--accent-press); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .scanline { top: 50%; }
}
@media (max-width: 360px) {
  :root { font-size: 17px; }
  .headline { font-size: 25px; }
  .row .label { width: 64px; }
  .seg span, .chips span { font-size: 15px; padding-inline: 8px; }
}
