/* =========================================================
   계정 · AI 고르기 · 관리자 화면
   app.css의 토큰(--paper, --pen, --amber …)만 써서 라이트/다크 모드를 그대로 따른다.
   ========================================================= */

/* ---------- 토큰 게이지 ---------- */
.tgauge { position: relative; display: inline-block; width: 44px; height: 6px; border-radius: 99px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; flex: none; vertical-align: middle; }
.tgauge i { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: var(--pen); transition: width 400ms var(--ease-out); }
.tgauge.is-low i { background: var(--amber); }
.tgauge--lg { width: 100%; height: 8px; }

/* ---------- 상단 계정 버튼 ---------- */
.acctbtn {
  position: relative; display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 12px 0 9px; border-radius: 10px;
  background: var(--paper); box-shadow: inset 0 0 0 1px var(--line-2); color: var(--ink-2); font-size: 14px; font-weight: 650; white-space: nowrap;
  transition: box-shadow 150ms ease, color 150ms ease, transform 160ms var(--ease-out);
}
.acctbtn[hidden] { display: none; }
.acctbtn:active { transform: scale(0.97); }
.acctbtn .ico { width: 18px; height: 18px; }
.acctbtn__ic { display: grid; place-items: center; }
.acctbtn__who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.acctbtn__t { max-width: 9em; overflow: hidden; text-overflow: ellipsis; }
.acctbtn__tok { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; color: var(--ink); }
.acctbtn__tok b { font-weight: 750; font-size: 13.5px; }
.acctbtn--user.is-empty .acctbtn__tok b { color: var(--red-ink); }
.acctbtn--admin { color: var(--ink); }
.acctbtn__badge { display: inline-flex; align-items: center; gap: 5px; }
.acctbtn--admin .acctbtn__badge .ico { color: var(--pen); }
.acctbtn__dot { position: absolute; top: 5px; right: 5px; width: 9px; height: 9px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 2px var(--paper); }
@media (hover: hover) and (pointer: fine) { .acctbtn:hover { color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink-3); } }

/* ---------- 로그인 · 계정 모달 ---------- */
.amodal { position: fixed; inset: 0; z-index: 85; display: grid; place-items: center; padding: 16px; }
.amodal[hidden] { display: none; }
.amodal__scrim { position: absolute; inset: 0; background: var(--scrim); opacity: 0; transition: opacity 200ms ease; }
.amodal__box {
  position: relative; width: min(420px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain;
  background: var(--paper); border-radius: 18px; box-shadow: var(--shadow-2), inset 0 0 0 1px var(--line);
  padding: 28px 24px 18px; opacity: 0; transform: translateY(8px) scale(0.985); transition: opacity 220ms var(--ease-out), transform 260ms var(--ease-out);
}
.amodal.is-on .amodal__scrim { opacity: 1; }
.amodal.is-on .amodal__box { opacity: 1; transform: none; }
.amodal__x { position: absolute; top: 10px; right: 10px; }
.amodal__mark { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--pen-soft); color: var(--pen); margin-bottom: 14px; }
.amodal__mark .ico { width: 22px; height: 22px; }
.amodal__mark--admin { background: var(--ink); color: var(--f2); }
.amodal__title { font-family: var(--font-display); font-size: 22px; font-weight: 700; letter-spacing: -0.02em; padding-right: 32px; }
.amodal__lead { margin-top: 8px; color: var(--ink-2); font-size: 14.5px; line-height: 1.65; }
.amodal__form { display: flex; flex-direction: column; gap: 6px; margin-top: 18px; }
.amodal__label { font-size: 13.5px; font-weight: 700; color: var(--ink-2); margin-top: 6px; }
.amodal__label small { font-weight: 600; color: var(--ink-3); }
.amodal__form .btn { margin-top: 12px; }
.field--code { font-family: ui-monospace, "SF Mono", Consolas, monospace; letter-spacing: 0.12em; text-transform: uppercase; font-size: 17px; font-weight: 650; }
.field--code::placeholder { letter-spacing: 0.12em; }
.amodal__err { margin-top: 4px; padding: 9px 12px; border-radius: 10px; background: var(--red-soft); color: var(--red-ink); font-size: 14px; line-height: 1.55; }
.amodal__err[hidden] { display: none; }
.amodal__alt { margin-top: 16px; font-size: 13.5px; color: var(--ink-3); line-height: 1.65; }
.amodal__note { margin-top: 14px; font-size: 13.5px; color: var(--ink-2); line-height: 1.6; padding: 10px 12px; border-radius: 10px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); display: flex; gap: 8px; align-items: flex-start; }
.amodal__note .ico { width: 18px; height: 18px; margin-top: 1px; }
.amodal__note--bad { background: var(--red-soft); color: var(--red-ink); box-shadow: none; }
.amodal__foot { display: flex; justify-content: center; gap: 16px; margin-top: 18px; padding-top: 12px; border-top: 1px dashed var(--line-2); }
.amodal__foot--split { justify-content: space-between; align-items: center; flex-wrap: wrap; }
.amodal__foot .linkbtn { display: inline-flex; align-items: center; gap: 5px; }
.amodal__foot .linkbtn .ico { width: 16px; height: 16px; }
.amodal__warn { font-size: 13px; color: var(--red-ink); flex: 1 1 200px; line-height: 1.5; }
.amodal__btns { display: flex; gap: 8px; flex-wrap: wrap; }
.amodal > .amodal__box > .btn, .amodal__body > .btn { margin-top: 14px; }
.linkbtn--quiet { color: var(--ink-3); font-weight: 600; }
@media (hover: hover) and (pointer: fine) { .linkbtn--quiet:hover { color: var(--ink); } }

/* 계정 카드 */
.acard { margin-top: 16px; padding: 14px 16px; border-radius: 14px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); display: flex; flex-direction: column; gap: 10px; }
.acard__big { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.acard__num { font-family: var(--font-display); font-variant-numeric: tabular-nums; }
.acard__num b { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; }
.acard__num small { font-family: var(--font-sans); font-size: 14px; color: var(--ink-3); font-weight: 600; margin-left: 4px; }
.acard__row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 14px; }
.acard__k { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 14px; }
.acard__k .ico { width: 17px; height: 17px; }
.acard__v { font-variant-numeric: tabular-nums; font-weight: 750; }
.acard__v.is-hot { color: var(--red-ink); }
.acard__note { font-size: 12.5px; color: var(--ink-3); line-height: 1.6; }

/* 토큰 요청 상태 */
.areq { display: flex; gap: 10px; align-items: flex-start; margin-top: 14px; padding: 12px 14px; border-radius: 12px; font-size: 14px; line-height: 1.55; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.areq .ico { width: 20px; height: 20px; margin-top: 1px; flex: none; }
.areq p { color: var(--ink-2); font-size: 13.5px; margin-top: 2px; }
.areq.is-pending { background: var(--amber-soft); box-shadow: inset 0 0 0 1px var(--amber-line); }
.areq.is-pending .ico { color: var(--amber-ink); }
.areq.is-approved .ico { color: var(--pen); }
.areq.is-denied .ico { color: var(--red-ink); }
.areq + .btn, .areq + .areqform { margin-top: 12px; }
.amodal__body > .btn--block { margin-top: 14px; }
.areqform textarea { min-height: 84px; }
.areqform .amodal__btns .btn { margin-top: 8px; }

/* ---------- 채팅: 지금 고른 AI 막대 ---------- */
.aibar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px 6px 12px; border-bottom: 1px solid var(--line); background: var(--surface); flex: none; min-height: 46px; }
.aibar__pick { display: inline-flex; align-items: center; gap: 7px; min-width: 0; height: 34px; padding: 0 8px 0 4px; border-radius: 9px; font-size: 14px; font-weight: 700; color: var(--ink); transition: background-color 150ms ease; }
.aibar__pick .ico { width: 16px; height: 16px; color: var(--ink-3); transition: transform 200ms var(--ease-out); }
.chat.is-settings .aibar__pick .ico { transform: rotate(180deg); }
.aibar__k { font-size: 10.5px; font-weight: 800; letter-spacing: 0.04em; padding: 2px 6px; border-radius: 5px; background: var(--ink); color: var(--paper); flex: none; }
.aibar__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aibar__meta { display: flex; align-items: center; min-width: 0; flex: none; }
.aibar__tag { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--ink-2); font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.aibar__tag b { color: var(--ink); font-weight: 750; }
.aibar__tag .ico { width: 15px; height: 15px; }
.aibar__tag--admin .ico { color: var(--pen); }
.aibar__tag.is-empty, .aibar__tag.is-empty b { color: var(--red-ink); }
.aibar__tok { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 8px; border-radius: 9px; font-size: 13px; color: var(--ink-2); font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.aibar__tok b { color: var(--ink); font-weight: 750; }
.aibar__tok small { color: var(--ink-3); font-size: 12px; }
.aibar__tok.is-empty b { color: var(--red-ink); }
.aibar__login { display: inline-flex; align-items: center; gap: 5px; height: 32px; padding: 0 10px; border-radius: 8px; font-size: 13px; font-weight: 700; color: var(--pen); box-shadow: inset 0 0 0 1px var(--pen-line); background: var(--paper); white-space: nowrap; }
.aibar__login .ico { width: 15px; height: 15px; }
@media (hover: hover) and (pointer: fine) {
  .aibar__pick:hover, .aibar__tok:hover { background: var(--surface-2); }
  .aibar__login:hover { box-shadow: inset 0 0 0 1px var(--pen); }
}

/* ---------- 채팅 설정: AI 고르기 ---------- */
.chat__settings { max-height: min(62dvh, 560px); overflow-y: auto; overscroll-behavior: contain; }
.set__row--head { justify-content: space-between; }
.set__v--srv { font-size: 12.5px; color: var(--ink-3); flex: 1; }
.aipick { display: flex; flex-direction: column; gap: 6px; }
.aiopt { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 54px; padding: 9px 12px; border-radius: 12px; text-align: left; background: var(--paper); box-shadow: inset 0 0 0 1px var(--line-2); transition: box-shadow 150ms ease, background-color 150ms ease; }
.aiopt__radio { width: 18px; height: 18px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--line-2); flex: none; display: grid; place-items: center; transition: box-shadow 150ms ease; }
.aiopt__radio::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--on-pen); transform: scale(0); transition: transform 180ms var(--ease-out); }
.aiopt__body { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.35; }
.aiopt__body b { font-size: 14.5px; font-weight: 700; }
.aiopt__body small { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.aiopt__tag { font-size: 12px; font-weight: 700; color: var(--ink-2); padding: 3px 8px; border-radius: 99px; background: var(--surface-2); white-space: nowrap; flex: none; }
.aiopt.is-on { background: var(--pen-soft); box-shadow: inset 0 0 0 1.5px var(--pen); }
.aiopt.is-on .aiopt__radio { background: var(--pen); box-shadow: none; }
.aiopt.is-on .aiopt__radio::after { transform: scale(1); }
.aiopt.is-on .aiopt__tag { background: var(--paper); }
@media (hover: hover) and (pointer: fine) { .aiopt:not(.is-on):hover { box-shadow: inset 0 0 0 1px var(--ink-3); } }
.set__detail { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 12px; background: var(--paper); box-shadow: inset 0 0 0 1px var(--line); }
.set__detail .set__btns { flex-wrap: wrap; }
.set__keyform { display: flex; flex-direction: column; gap: 8px; }
.seg--prov { display: flex; width: 100%; }
.seg--prov .seg__b { flex: 1 1 0; padding: 0 6px; font-size: 13.5px; position: relative; min-width: 0; }
.seg__dot { position: absolute; top: 6px; right: 6px; width: 6px; height: 6px; border-radius: 50%; background: var(--pen); }
.extlink { display: inline-flex; align-items: center; gap: 3px; color: var(--pen); font-weight: 650; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.extlink .ico { width: 14px; height: 14px; }
.set__note--warn { display: flex; gap: 8px; align-items: flex-start; padding: 9px 11px; border-radius: 10px; background: var(--amber-soft); color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--amber-line); }
.set__note--warn .ico { width: 16px; height: 16px; margin-top: 2px; color: var(--amber-ink); flex: none; }
.set__tok { display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.dot--unknown { background: var(--line-2); }

/* 안내 상자 버튼 줄 */
.notice__btns { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-top: 8px; }
.notice__btns .btn .ico { width: 16px; height: 16px; }
.notice__ok { display: flex; gap: 6px; align-items: center; color: var(--ink-2); }
.notice__ok .ico { width: 16px; height: 16px; color: var(--amber-ink); }
.chat__status.is-unknown i { background: var(--line-2); }

/* 말풍선 아래 '어떤 AI가 답했는지' */
.msg--ai { flex-direction: column; }
.msg__meta { display: inline-flex; align-items: center; gap: 5px; margin-top: 6px; font-size: 12px; font-weight: 600; color: var(--ink-3); }
.msg__meta .ico { width: 12px; height: 12px; fill: currentColor; stroke: none; opacity: 0.8; }
.msg__errActions { flex-wrap: wrap; }
.chat__fine.is-free { color: var(--amber-ink); }

/* =========================================================
   관리자 화면
   ========================================================= */
.admin__head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.admin__tools { display: flex; gap: 8px; }
.admin__loading { color: var(--ink-3); padding: 40px 0; text-align: center; }
.admin__lock { width: 52px; height: 52px; border-radius: 14px; margin: 0 auto 14px; display: grid; place-items: center; background: var(--ink); color: var(--f2); }
.admin__lock .ico { width: 26px; height: 26px; }
.admin__note { font-size: 13px; color: var(--ink-3); line-height: 1.65; margin-top: 12px; }
.admin__tabs { display: flex; gap: 2px; padding: 4px; border-radius: 12px; background: var(--surface-2); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.admin__tabs::-webkit-scrollbar { display: none; }
.admin__tab { position: relative; display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 16px; border-radius: 9px; font-size: 14.5px; font-weight: 650; color: var(--ink-2); white-space: nowrap; flex: 1 0 auto; justify-content: center; transition: background-color 150ms ease, color 150ms ease, box-shadow 150ms ease; }
.admin__tab.is-on { background: var(--paper); color: var(--ink); box-shadow: var(--shadow-1); }
@media (hover: hover) and (pointer: fine) { .admin__tab:not(.is-on):hover { color: var(--ink); } }
.admin__badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--red); color: white; font-size: 12px; font-weight: 800; display: inline-grid; place-items: center; font-variant-numeric: tabular-nums; }
.admin__panel { display: flex; flex-direction: column; gap: 18px; }

.astats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.astat { display: flex; flex-direction: column; gap: 2px; padding: 16px 18px; border-radius: 14px; background: var(--paper); box-shadow: var(--shadow-1), inset 0 0 0 1px var(--line); min-width: 0; }
.astat__k { font-size: 13px; font-weight: 650; color: var(--ink-2); }
.astat__v { font-family: var(--font-display); font-size: 28px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.astat__s { font-size: 12.5px; color: var(--ink-3); }
.astat.is-hot { box-shadow: var(--shadow-1), inset 0 0 0 1.5px var(--red-line); background: var(--red-soft); }
.astat.is-hot .astat__v { color: var(--red-ink); }

.acardx { padding: 18px 20px; border-radius: 16px; background: var(--paper); box-shadow: var(--shadow-1), inset 0 0 0 1px var(--line); min-width: 0; }
.acardx__h { font-size: 16px; font-weight: 750; letter-spacing: -0.015em; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.acardx__n { font-size: 12.5px; font-weight: 750; color: var(--ink-2); background: var(--surface-2); padding: 1px 8px; border-radius: 99px; font-variant-numeric: tabular-nums; }

.abars { display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 6px; align-items: end; height: 120px; padding-top: 6px; }
.abars__c { display: flex; flex-direction: column; align-items: stretch; justify-content: flex-end; height: 100%; gap: 4px; }
.abars__c i { display: block; border-radius: 4px 4px 2px 2px; background: var(--pen); opacity: 0.85; min-height: 1px; }
.abars__c span { font-size: 11px; color: var(--ink-3); text-align: center; font-variant-numeric: tabular-nums; }

.atable { overflow-x: auto; border-radius: 10px; box-shadow: inset 0 0 0 1px var(--line); margin-top: 10px; }
.atable table { width: 100%; border-collapse: collapse; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.atable caption { text-align: left; font-size: 13px; font-weight: 700; color: var(--ink-2); padding: 10px 12px 4px; }
.atable th, .atable td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.atable thead th { font-size: 12.5px; color: var(--ink-3); font-weight: 700; background: var(--surface); }
.atable th:first-child, .atable td:first-child { text-align: left; }
.atable tbody th { font-weight: 650; }
.atable tr:last-child td, .atable tr:last-child th { border-bottom: 0; }
.atable__empty { font-size: 14px; color: var(--ink-3); padding: 14px 4px; }

.akeys { list-style: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.akeys__i { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; background: var(--surface); font-size: 13.5px; min-width: 0; }
.akeys__i span:last-child { display: flex; flex-direction: column; min-width: 0; }
.akeys__i small { color: var(--ink-3); font-size: 12.5px; overflow-wrap: anywhere; }
.akeys__dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line-2); margin-top: 6px; flex: none; }
.akeys__i.is-ok .akeys__dot { background: oklch(0.68 0.15 150); }

.achip { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 99px; font-size: 12px; font-weight: 750; white-space: nowrap; background: var(--surface-2); color: var(--ink-2); flex: none; }
.achip--ok, .achip--approved { background: var(--pen-soft); color: var(--pen); }
.achip--off, .achip--denied { background: var(--red-soft); color: var(--red-ink); }
.achip--expired, .achip--full { background: var(--amber-soft); color: var(--amber-ink); }

.areqs { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.areqc { display: flex; flex-direction: column; gap: 8px; padding: 14px; border-radius: 12px; background: var(--amber-soft); box-shadow: inset 0 0 0 1px var(--amber-line); }
.areqc__top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.areqc__who { font-size: 15.5px; }
.areqc__when { font-size: 12.5px; color: var(--ink-3); }
.areqc__why { font-size: 14.5px; line-height: 1.6; overflow-wrap: anywhere; }
.areqc__meta { font-size: 12.5px; color: var(--ink-2); }
.areqc__form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.areqc__amt { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 14px; }
.areqc__amt .field { width: 90px; text-align: right; font-variant-numeric: tabular-nums; }
.areqc__note { flex: 1 1 140px; min-width: 0; width: auto; }
.areqc__btns { display: flex; gap: 6px; width: 100%; }
.areqc__btns .btn { flex: 1; }
.ahist { list-style: none; display: flex; flex-direction: column; }
.ahist li { display: flex; align-items: center; gap: 10px; padding: 9px 2px; border-bottom: 1px dashed var(--line-2); font-size: 14px; min-width: 0; }
.ahist li:last-child { border-bottom: 0; }
.ahist__why { flex: 1; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; font-size: 13.5px; }
.ahist__when { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; }

.ainvf { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1.2fr) auto; gap: 10px; align-items: end; }
.ainvf__f { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ainvf__f label { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.ainvf__f label small, .ainvf__f > small { font-weight: 600; color: var(--ink-3); font-size: 12px; }
.ainvf__f--n { position: relative; }
.ainvf__f--n > small { position: absolute; top: calc(100% + 2px); left: 0; white-space: nowrap; }
.ainvf__go { height: 38px; }
.ainvf ~ .admin__note { margin-top: 26px; }
.anewcode { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 26px; padding: 12px 14px; border-radius: 12px; background: var(--pen-soft); box-shadow: inset 0 0 0 1px var(--pen-line); }
.anewcode span { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.anewcode code { font-size: 20px; font-weight: 750; letter-spacing: 0.1em; background: var(--paper); padding: 4px 10px; border-radius: 8px; }
.ainvs { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.ainv { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "main btns" "meta btns"; gap: 4px 12px; align-items: center; padding: 12px 14px; border-radius: 12px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.ainv.is-dim { opacity: 0.72; }
.ainv__main { grid-area: main; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.ainv__code { font-size: 16px; font-weight: 750; letter-spacing: 0.08em; background: var(--paper); }
.ainv__memo { font-size: 14px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.ainv__meta { grid-area: meta; font-size: 12.5px; color: var(--ink-3); }
.ainv__btns { grid-area: btns; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.ausers { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 12px; }
.auser { display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: 12px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); min-width: 0; }
.auser.is-blocked { background: var(--red-soft); box-shadow: inset 0 0 0 1px var(--red-line); }
.auser__top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.auser__name { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.auser__seen { margin-left: auto; font-size: 12.5px; color: var(--ink-3); white-space: nowrap; }
.auser__bal { display: flex; flex-direction: column; gap: 8px; }
.auser__bal dl { margin: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.auser__bal dt { font-size: 11.5px; color: var(--ink-3); font-weight: 650; }
.auser__bal dd { margin: 0; font-weight: 750; font-variant-numeric: tabular-nums; font-size: 15px; white-space: nowrap; }
.auser__bal dd small { font-size: 11.5px; color: var(--ink-3); font-weight: 600; }
.auser__row { display: grid; grid-template-columns: 76px minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.auser__row label { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.auser__btns { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding-top: 8px; border-top: 1px dashed var(--line-2); }
.auser__inv { font-size: 12px; color: var(--ink-3); margin-right: auto; }

.aset { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.aset__f { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.aset__f label { font-size: 13.5px; font-weight: 700; color: var(--ink-2); }
.aset__f small { font-size: 12.5px; color: var(--ink-3); line-height: 1.55; }
.aset__go { grid-column: 1 / -1; }

/* ---------- 반응형 ---------- */
/* 태블릿·작은 노트북: 계정 버튼이 들어갈 자리를 만들기 위해 상단 바를 조금 촘촘하게 */
@media (min-width: 820px) and (max-width: 1180px) {
  .topnav a { white-space: nowrap; }
  .acctbtn__t { display: none; }
  .acctbtn--guest .acctbtn__t--guest { display: none; }
  .acctbtn { padding: 0 10px; }
}
@media (min-width: 820px) and (max-width: 1023px) {
  .topbar__inner { gap: 14px; }
  .topnav a { padding: 0 9px; }
  .topnav a::after { left: 9px; right: 9px; }
  .brand__name small { display: none; }
  .searchbtn { min-width: 0; width: 38px; padding: 0; justify-content: center; }
  .searchbtn__label, .searchbtn__kbd { display: none; }
}
@media (min-width: 1024px) and (max-width: 1180px) {
  .searchbtn { min-width: 150px; }
}
@media (min-width: 1024px) and (max-width: 1439px) {
  body.chat-open .astats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body.chat-open .ainvf { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  body.chat-open .akeys, body.chat-open .aset { grid-template-columns: minmax(0, 1fr); }
  body.chat-open .acctbtn__t { max-width: 6em; }
}
@media (max-width: 1023px) {
  .astats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 819px) {
  .acctbtn { height: 38px; padding: 0 10px; }
  .acctbtn--guest .acctbtn__t--guest { display: inline; }
  .acctbtn--user .acctbtn__t { max-width: 5.5em; }
  .acctbtn--user .tgauge { width: 28px; }
  .ainvf { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .ainvf__f:first-child { grid-column: 1 / -1; }
  .ainvf__go { grid-column: 1 / -1; margin-top: 18px; }
  .akeys, .aset { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .amodal { place-items: end center; padding: 0; }
  .amodal__box { width: 100%; max-height: calc(100dvh - 24px); border-radius: 18px 18px 0 0; padding: 24px max(18px, var(--sar)) max(18px, var(--sab)) max(18px, var(--sal)); transform: translateY(24px); }
  .admin__head { align-items: flex-start; }
  .admin__tools { width: 100%; }
  .admin__tools .btn { flex: 1; }
  .admin__tab { padding: 0 12px; font-size: 14px; }
  .astat { padding: 14px; }
  .astat__v { font-size: 22px; }
  .acardx { padding: 16px 14px; border-radius: 14px; }
  .abars { gap: 3px; height: 100px; }
  .ausers, .areqs { grid-template-columns: minmax(0, 1fr); }
  .auser__bal dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ainv { grid-template-columns: minmax(0, 1fr); grid-template-areas: "main" "meta" "btns"; }
  .ainv__btns { justify-content: flex-start; }
  .acctbtn--user .acctbtn__t { display: none; }
  .acctbtn--admin .acctbtn__t { display: none; }
  .acctbtn--guest .acctbtn__t--guest { display: none; }
  .acctbtn { width: auto; min-width: 38px; padding: 0 9px; justify-content: center; }
  .aibar__tok small { display: none; }
}
@media (max-width: 380px) {
  .aibar__name { max-width: 9.5em; }
  .acctbtn--user .tgauge { display: none; }
}

/* 터치 기기: 누르기 쉬운 크기 */
@media (pointer: coarse) {
  .acctbtn { min-height: 44px; min-width: 44px; }
  .aibar__pick, .aibar__tok, .aibar__login { min-height: 44px; }
  .aiopt { min-height: 56px; }
  .seg--prov .seg__b { min-height: 44px; }
  .admin__tab { min-height: 44px; }
  .amodal__foot .linkbtn { min-height: 44px; }
  .field--code { font-size: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  .amodal__box, .amodal__scrim, .tgauge i, .aiopt__radio::after { transition: none !important; }
}
@media print {
  .acctbtn, .amodal { display: none !important; }
}

/* =========================================================
   로그인 화면 (gate) — 로그인하기 전에는 이것만 보여요
   공책 표지(왼쪽, 남색) + 속지(오른쪽, 종이) + 오른쪽 가장자리의 단원 인덱스 탭
   ========================================================= */
:root {
  --cover: oklch(0.285 0.04 264);
  --cover-2: oklch(0.33 0.045 264);
  --on-cover: oklch(0.975 0.006 260);
  --on-cover-2: oklch(0.84 0.025 264);
  --ok-ink: oklch(0.50 0.13 150);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --cover: oklch(0.255 0.032 264); --cover-2: oklch(0.30 0.036 264); --ok-ink: oklch(0.80 0.12 150); }
}
:root[data-theme="dark"] { --cover: oklch(0.255 0.032 264); --cover-2: oklch(0.30 0.036 264); --ok-ink: oklch(0.80 0.12 150); }

/* 로그인 확인 중(checking)·로그인 전(out)에는 앱 화면을 숨긴다 */
html[data-auth="checking"] .shell, html[data-auth="out"] .shell,
html[data-auth="checking"] .topbar, html[data-auth="checking"] .main, html[data-auth="checking"] .tabbar,
html[data-auth="checking"] .chat, html[data-auth="checking"] .chat-scrim, html[data-auth="checking"] .askpop,
html[data-auth="out"] .topbar, html[data-auth="out"] .main, html[data-auth="out"] .tabbar,
html[data-auth="out"] .chat, html[data-auth="out"] .chat-scrim, html[data-auth="out"] .askpop { display: none !important; }
html[data-auth="in"] .gate { display: none; }

/* 로그인 화면도 앱 껍데기 안에서 스스로 스크롤한다 (창은 스크롤하지 않음) */
.gate {
  flex: 1 1 auto; min-height: 0; overflow-x: hidden; overflow-y: auto; overscroll-behavior-y: contain; -webkit-overflow-scrolling: touch;
  display: grid; place-items: center; place-items: safe center;
  padding: max(28px, env(safe-area-inset-top, 0px)) max(20px, var(--sar)) max(28px, var(--sab)) max(20px, var(--sal));
}
.gate__splash { display: none; }
html[data-auth="checking"] .gate__splash { display: grid; place-items: center; opacity: 0; animation: gateFade 400ms ease 350ms forwards; }
html[data-auth="checking"] .gate__splash .brand__mark { transform: scale(1.5); }
html[data-auth="checking"] .gate__body { display: none; }
.gate__body { width: 100%; display: grid; place-items: center; }

.gate__book {
  position: relative; width: min(1040px, 100%); display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.04fr);
  border-radius: 22px; background: var(--paper); box-shadow: var(--shadow-2), inset 0 0 0 1px var(--line);
  animation: gateIn 460ms var(--ease-out) both;
}
.gate__cover {
  position: relative; display: flex; flex-direction: column; gap: 18px; padding: 48px 44px 44px 52px; overflow: hidden;
  border-radius: 22px 0 0 22px; color: var(--on-cover);
  background-color: var(--cover);
  background-image: radial-gradient(oklch(1 0 0 / 0.07) 1px, transparent 1.3px), linear-gradient(160deg, var(--cover-2), var(--cover) 60%);
  background-size: 22px 22px, 100% 100%;
  background-position: 11px 11px, 0 0;
  box-shadow: inset 12px 0 0 oklch(0 0 0 / 0.14), inset 13px 0 0 oklch(1 0 0 / 0.06);
}
.gate__brand { display: flex; align-items: center; gap: 12px; }
.gate__mark { background: var(--on-cover); transform: scale(1.1); transform-origin: left center; }
.gate__brandname { font-family: var(--font-display); font-weight: 700; font-size: 19px; letter-spacing: -0.02em; display: flex; align-items: baseline; gap: 7px; margin-left: 6px; }
.gate__brandname small { font-family: var(--font-sans); font-size: 12.5px; font-weight: 600; color: var(--on-cover-2); letter-spacing: 0; }
.gate__title { margin-top: 18px; font-family: var(--font-display); font-size: clamp(30px, 3.3vw, 40px); font-weight: 700; line-height: 1.22; letter-spacing: -0.03em; text-wrap: balance; }
.gate__lead { color: var(--on-cover-2); font-size: 15.5px; line-height: 1.7; max-width: 34ch; }
.gate__feats { list-style: none; display: grid; gap: 12px; margin-top: auto; padding-top: 18px; }
.gate__feats li { display: flex; align-items: center; gap: 12px; min-width: 0; }
.gate__feats b { display: block; font-size: 15px; font-weight: 700; }
.gate__feats small { display: block; font-size: 13px; color: var(--on-cover-2); line-height: 1.45; }
.gate__fic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--flag); color: var(--tab-ink); }
.gate__fic .ico { width: 19px; height: 19px; }

.gate__page { position: relative; display: flex; flex-direction: column; justify-content: center; min-height: 620px; padding: 48px 48px 36px; }
.gate__theme { position: absolute; top: 12px; right: 12px; color: var(--on-cover-2); }
@media (hover: hover) and (pointer: fine) { .gate__theme:hover { background: oklch(1 0 0 / 0.1); color: var(--on-cover); } }
.gate__panel { width: 100%; max-width: 400px; margin: 0 auto; }
.gate__page > .gate__seg { width: 100%; max-width: 400px; margin: 0 auto 26px; }
.gate__seg { display: flex; padding: 4px; border-radius: 12px; background: var(--surface-2); gap: 2px; }
.gate__segb { flex: 1 1 0; height: 40px; border-radius: 9px; font-size: 15px; font-weight: 700; color: var(--ink-2); transition: background-color 150ms ease, color 150ms ease, box-shadow 150ms ease; }
.gate__segb.is-on { background: var(--paper); color: var(--ink); box-shadow: var(--shadow-1); }
@media (hover: hover) and (pointer: fine) { .gate__segb:not(.is-on):hover { color: var(--ink); } }
.gate__h { font-family: var(--font-display); font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.gate__sub { margin-top: 6px; color: var(--ink-2); font-size: 15px; line-height: 1.6; }
.gate__sub code { white-space: nowrap; }
.gate__form { display: flex; flex-direction: column; gap: 14px; margin-top: 22px; }
.gfield { display: flex; flex-direction: column; gap: 6px; }
.gfield__label { font-size: 14px; font-weight: 700; color: var(--ink-2); }
.gfield__label small { font-weight: 600; color: var(--ink-3); }
.gfield__hint { font-size: 12.5px; color: var(--ink-3); line-height: 1.5; }
.gfield__hint.is-ok { color: var(--ok-ink); }
.gfield__hint.is-bad { color: var(--red-ink); }
.gpw { position: relative; }
.gpw .field { padding-right: 50px; }
.gpw__eye { position: absolute; right: 3px; top: 50%; transform: translateY(-50%); width: 42px; height: 40px; display: grid; place-items: center; border-radius: 8px; color: var(--ink-3); transition: color 150ms ease, background-color 150ms ease; }
.gpw__eye .ico { width: 19px; height: 19px; }
@media (hover: hover) and (pointer: fine) { .gpw__eye:hover { color: var(--ink); background: var(--surface-2); } }
.gate__err { padding: 10px 12px; border-radius: 10px; background: var(--red-soft); color: var(--red-ink); font-size: 14px; line-height: 1.55; }
.gate__err[hidden] { display: none; }
.gate__go { margin-top: 4px; }
.gate__go:disabled { opacity: 0.75; }
.gate__spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: gateSpin 700ms linear infinite; flex: none; }
.gate__alt { margin-top: 20px; font-size: 14px; color: var(--ink-2); text-align: center; }
.gate__help { margin-top: 8px; font-size: 12.5px; color: var(--ink-3); text-align: center; line-height: 1.55; }
.gate__banner { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 16px; padding: 10px 12px; border-radius: 10px; background: var(--amber-soft); box-shadow: inset 0 0 0 1px var(--amber-line); color: var(--ink); font-size: 14px; line-height: 1.5; }
.gate__banner .ico { width: 18px; height: 18px; color: var(--amber-ink); }
.gate__banner span { flex: 1 1 200px; }
.gate__tabs { position: absolute; right: -9px; top: 64px; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.gate__tabs i { display: block; width: 9px; height: 34px; border-radius: 0 5px 5px 0; background: var(--flag); }

@keyframes gateFade { to { opacity: 1; } }
@keyframes gateIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes gateSpin { to { transform: rotate(360deg); } }

/* 태블릿·휴대폰: 표지를 위쪽 띠로 */
@media (max-width: 899px) {
  .gate { place-items: start center; }
  .gate__book { grid-template-columns: minmax(0, 1fr); width: min(560px, 100%); }
  .gate__cover { border-radius: 22px 22px 0 0; padding: 30px 28px 26px 34px; gap: 12px; box-shadow: inset 8px 0 0 oklch(0 0 0 / 0.14); }
  .gate__title { margin-top: 10px; font-size: 28px; }
  .gate__lead { max-width: none; }
  .gate__feats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; padding-top: 8px; }
  .gate__feats small { display: none; }
  .gate__feats b { font-size: 14px; }
  .gate__fic { width: 30px; height: 30px; border-radius: 8px; }
  .gate__fic .ico { width: 17px; height: 17px; }
  .gate__page { min-height: 0; padding: 30px 28px 26px; }
  .gate__tabs { top: 28px; }
}
@media (max-width: 640px) {
  .gate { padding: max(12px, env(safe-area-inset-top, 0px)) max(12px, var(--sar)) max(16px, var(--sab)) max(12px, var(--sal)); }
  .gate__book { border-radius: 18px; }
  .gate__cover { border-radius: 18px 18px 0 0; padding: 22px 20px 20px 26px; }
  .gate__brandname { font-size: 17px; }
  .gate__title { font-size: 23px; }
  .gate__lead { font-size: 14px; line-height: 1.6; }
  .gate__feats { display: none; }
  .gate__page { padding: 22px 18px 20px; }
  .gate__page > .gate__seg { margin-bottom: 20px; }
  .gate__h { font-size: 22px; }
  .gate__sub { font-size: 14px; }
  .gate__theme { top: 8px; right: 8px; }
  .gate__tabs { display: none; }
}
@media (pointer: coarse) {
  .gate__segb { min-height: 44px; }
  .gpw__eye { width: 44px; height: 44px; }
}

/* =========================================================
   내 계정 창 · 관리자 화면에 새로 생긴 부분
   ========================================================= */
.amodal__title .achip { vertical-align: 4px; margin-left: 4px; font-family: var(--font-sans); letter-spacing: 0; }
.amodal__meta { font-size: 12.5px; color: var(--ink-3); }
.asec { margin-top: 18px; }
.asec__h { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; font-size: 15px; font-weight: 750; margin-bottom: 8px; }
.asec__h .ico { width: 18px; height: 18px; color: var(--ink-3); }
.asec__h small { font-weight: 600; color: var(--ink-3); }
.asec .acard { margin-top: 0; }
.asec--quiet { margin-top: 14px; }
.asec--quiet .linkbtn { display: inline-flex; align-items: center; gap: 6px; }
.asec--quiet .linkbtn .ico { width: 16px; height: 16px; }
.asec .amodal__note { margin: 0 0 10px; }
.ainvite { padding: 14px 16px; border-radius: 14px; background: var(--pen-soft); box-shadow: inset 0 0 0 1px var(--pen-line); font-size: 14px; line-height: 1.6; color: var(--ink-2); }
.ainvite b { color: var(--ink); }
.ainvite__form { display: flex; gap: 8px; margin-top: 10px; }
.ainvite__form .field { flex: 1 1 auto; min-width: 0; height: 44px; }
.ainvite__form .btn { height: 44px; flex: none; }
.ainvite .amodal__err { margin-top: 8px; }
.apwform .acard__note { margin-top: 2px; }
.amodal__foot--split .btn .ico { width: 16px; height: 16px; }

/* 상단 계정 버튼: 초대 코드 없는 계정 */
.acctbtn--plain .acctbtn__t { max-width: 8em; }

/* AI 고르기: 잠긴 사이트 Claude */
.aiopt__tag { display: inline-flex; align-items: center; gap: 3px; }
.aiopt__tag .ico { width: 13px; height: 13px; }
.aiopt.is-locked:not(.is-on) .aiopt__body b { color: var(--ink-2); }
.set__note--lock { display: flex; gap: 8px; align-items: flex-start; }
.set__note--lock .ico { width: 16px; height: 16px; margin-top: 3px; color: var(--pen); flex: none; }

/* 관리자 · 계정 탭 */
.acardx__top { display: flex; align-items: center; justify-content: space-between; gap: 10px 14px; flex-wrap: wrap; }
.acardx__top .acardx__h { margin-bottom: 0; }
.ausers__find { position: relative; display: flex; align-items: center; width: min(260px, 100%); }
.ausers__find .ico { position: absolute; left: 11px; width: 16px; height: 16px; color: var(--ink-3); pointer-events: none; }
.ausers__find .field { padding-left: 34px; }
.admin__note--top { margin: 8px 0 14px; }
.auser[hidden] { display: none; }
.auser__top { flex-wrap: wrap; row-gap: 6px; }
.auser__name { margin-right: 2px; }
.auser__facts { margin: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; padding: 10px 12px; border-radius: 10px; background: var(--paper); box-shadow: inset 0 0 0 1px var(--line); }
.auser__facts dt { font-size: 11.5px; color: var(--ink-3); font-weight: 650; }
.auser__facts dd { margin: 0; font-weight: 700; font-size: 14px; white-space: nowrap; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; }
.auser__facts dd small { font-size: 11.5px; color: var(--ink-3); font-weight: 600; }
.auser__row label { white-space: nowrap; }
.auser__btns .auser__del { margin-left: auto; color: var(--red-ink); }
.auser__confirm { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 10px; background: var(--paper); box-shadow: inset 0 0 0 1.5px var(--pen-line); font-size: 13.5px; line-height: 1.55; }
.auser__confirm--bad { background: var(--red-soft); box-shadow: inset 0 0 0 1.5px var(--red-line); }
.auser__confirmRow { display: flex; gap: 6px; flex-wrap: wrap; }
.auser__confirmRow .field { flex: 1 1 180px; min-width: 0; }
.apwshow { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 16px; margin-bottom: 14px; border-radius: 12px; background: var(--amber-soft); box-shadow: inset 0 0 0 1px var(--amber-line); }
.apwshow__k { display: block; font-size: 13.5px; color: var(--ink-2); }
.apwshow__pw { display: inline-block; margin: 6px 0; font-size: 20px; font-weight: 750; letter-spacing: 0.06em; background: var(--paper); padding: 4px 10px; border-radius: 8px; user-select: all; }
.apwshow p { font-size: 12.5px; color: var(--ink-2); line-height: 1.55; }
.apwshow__btns { display: flex; gap: 6px; }
.ainv__who { color: var(--ink-2); }

@media (max-width: 819px) {
  .acctbtn--plain .acctbtn__t { max-width: 6em; }
}
@media (min-width: 820px) and (max-width: 1180px) {
  .acctbtn--plain .acctbtn__t { display: none; }
}
@media (max-width: 640px) {
  .acctbtn--plain .acctbtn__t { display: none; }
  .auser__facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ausers__find { width: 100%; }
  .auser__btns .auser__del { margin-left: 0; }
}
@media (max-width: 440px) {
  .aibar__long { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .gate__book, html[data-auth="checking"] .gate__splash { animation: none !important; opacity: 1; }
  .gate__spin { animation-duration: 1.6s; }
}
@media print {
  .gate { display: none !important; }
}
