/* Haneul chat app: chat-app layout (plain answers, gray user bubbles, pill composer, drawer or sidebar)
   with spring motion like iOS. Everything moves with transform/opacity only, and stops for reduced motion. */
:root {
  --bg: #ffffff; --fg: #0d0d0d; --muted: #5d5d5d; --faint: #8f8f8f; --line: #e8e8ea;
  --bubble: #f2f2f4; --surface: #f7f7f8; --hover: #ececee; --danger: #e5484d; --accent: #3b82f6;
  --glass: rgba(255, 255, 255, .72);
  --sky1: #7cc4ff; --sky2: #4a7dff; --sky3: #b388ff;
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --ease: cubic-bezier(.22, 1, .36, 1);
  --shadow: 0 10px 40px rgba(0, 0, 0, .12), 0 2px 8px rgba(0, 0, 0, .06);
  font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Segoe UI", sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #161618; --fg: #ededef; --muted: #b4b4b8; --faint: #8e8e93; --line: #2c2c2f;
          --bubble: #2a2a2d; --surface: #1d1d20; --hover: #2c2c30; --glass: rgba(30, 30, 33, .72);
          --shadow: 0 10px 40px rgba(0, 0, 0, .5), 0 2px 8px rgba(0, 0, 0, .3); }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); }
body { font-size: 16px; line-height: 1.6; -webkit-text-size-adjust: 100%; -webkit-font-smoothing: antialiased; overscroll-behavior: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

/* every tappable thing gives a soft squeeze */
.press { transition: transform .35s var(--spring), background-color .2s, opacity .2s; }
.press:active { transform: scale(.92); transition-duration: .08s; }

/* the sky orb: logo, greeting and sign-in */
.orb { width: 64px; height: 64px; margin: 0 auto; border-radius: 50%; position: relative;
       background: conic-gradient(from 0deg, var(--sky1), var(--sky2), var(--sky3), var(--sky1));
       filter: saturate(1.1); animation: spin 8s linear infinite, breathe 4s var(--ease) infinite;
       box-shadow: 0 8px 30px rgba(74, 125, 255, .35); }
.orb::after { content: ""; position: absolute; inset: 7px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.95), rgba(255,255,255,.25) 45%, transparent 70%); }
@keyframes spin { to { rotate: 360deg; } }
@keyframes breathe { 50% { scale: 1.06; } }

/* sign in / install pages */
.auth { max-width: 380px; margin: 0 auto; padding: 12vh 24px 24px; display: flex; flex-direction: column; gap: 14px; text-align: center; animation: rise .7s var(--ease) both; }
.auth-logo { width: 72px; height: 72px; margin: 0 auto; border-radius: 18px; }
.auth h1 { margin: 0; font-size: 1.8rem; letter-spacing: -.02em; }
.auth label { text-align: left; font-weight: 600; display: flex; flex-direction: column; gap: 6px; }
.auth select, .auth input { width: 100%; padding: 13px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg); transition: border-color .2s, box-shadow .2s; }
.auth input:focus, .auth select:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 4px rgba(59, 130, 246, .15); }
.auth-actions { display: flex; gap: 10px; }
.auth-actions button { flex: 1; padding: 13px; border-radius: 999px; background: var(--fg); color: var(--bg); font-weight: 600; }
.auth-actions button.ghost { background: var(--bubble); color: var(--fg); }
.muted { color: var(--muted); margin: 0; }
.small { font-size: .85rem; }
.error { color: var(--danger); min-height: 1.2em; margin: 0; }
.install .step { text-align: left; background: var(--bubble); border-radius: 16px; padding: 14px 16px; animation: rise .6s var(--ease) both; }
.install .step p { margin: 0 0 8px; }
.install .step p:last-child { margin: 0; }
.big { display: block; width: 100%; padding: 15px; border-radius: 999px; background: var(--fg); color: var(--bg); font-weight: 600; font-size: 1.05rem; text-align: center; text-decoration: none; margin-bottom: 10px; }
.big.link { background: var(--bubble); color: var(--fg); }
@keyframes rise { from { opacity: 0; transform: translateY(16px) scale(.98); filter: blur(6px); } }

/* chat layout */
.app { height: 100dvh; display: flex; flex-direction: column; position: relative; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: max(6px, env(safe-area-inset-top)) 8px 6px;
       position: relative; z-index: 2; background: var(--glass); backdrop-filter: saturate(1.8) blur(18px); -webkit-backdrop-filter: saturate(1.8) blur(18px); }
.title { font-weight: 650; font-size: 1.05rem; letter-spacing: -.01em; }
.top-actions { display: flex; align-items: center; gap: 2px; }
.icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: var(--fg); position: relative; }
.icon:hover { background: var(--hover); }
.new-chat { display: flex; align-items: center; gap: 6px; height: 38px; padding: 0 14px 0 11px; border-radius: 999px; background: var(--bubble); font-weight: 600; font-size: .9rem; }
.new-chat svg { width: 18px; height: 18px; }
.new-chat:hover { background: var(--hover); }
.badge { position: absolute; top: 6px; right: 6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff;
         font-size: .68rem; font-weight: 700; display: grid; place-items: center; line-height: 1; animation: pop .5s var(--spring); }
.inline-badge { position: static; margin-left: auto; }
@keyframes pop { from { transform: scale(0); } }

.log { flex: 1; overflow-y: auto; padding: 8px max(18px, calc((100% - 760px) / 2)) 28px; display: flex; flex-direction: column; gap: 22px; scroll-behavior: smooth; }
.empty { margin: auto 0; text-align: center; display: flex; flex-direction: column; gap: 10px; animation: rise .8s var(--ease) both; }
.empty h2 { font-size: 1.6rem; font-weight: 650; margin: 10px 0 0; letter-spacing: -.02em; }
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 18px; text-align: left; }
.card { display: flex; flex-direction: column; gap: 2px; padding: 14px; border: 1px solid var(--line); border-radius: 18px; background: var(--bg);
        animation: rise .7s var(--ease) both; }
.card:nth-child(2) { animation-delay: .06s; } .card:nth-child(3) { animation-delay: .12s; } .card:nth-child(4) { animation-delay: .18s; }
.card:hover { background: var(--surface); }
.card-icon { font-size: 1.25rem; margin-bottom: 4px; }
.card b { font-weight: 600; font-size: .93rem; }
.card span:last-child { color: var(--faint); font-size: .84rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* messages slide up and come into focus */
.msg { animation: msg-in .55s var(--ease) both; }
@keyframes msg-in { from { opacity: 0; transform: translateY(14px) scale(.98); filter: blur(4px); } }
.msg.user { display: flex; flex-direction: column; align-items: flex-end; }
.msg.user .body { background: var(--bubble); padding: 10px 18px; border-radius: 22px 22px 6px 22px; max-width: 80%; white-space: pre-wrap; word-break: break-word; transform-origin: bottom right; animation: bubble .5s var(--spring) both; }
@keyframes bubble { from { transform: scale(.85); opacity: 0; } }
.msg.bot .body { word-break: break-word; line-height: 1.75; }
.msg.error .body { color: var(--danger); }
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--faint); margin-bottom: 10px; padding: 4px 10px; border-radius: 999px; background: var(--surface); }
.sources { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.sources a { font-size: .78rem; padding: 4px 11px; border-radius: 999px; background: var(--bubble); color: var(--muted); text-decoration: none; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: background .2s; }
.sources a:hover { background: var(--hover); }

/* icon-only actions under an answer, like chat apps; a small label appears on hover */
.actions { display: flex; gap: 2px; margin: 6px 0 0 -6px; opacity: 0; animation: fade .4s .15s var(--ease) forwards; }
.actions button { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; color: var(--faint); position: relative; }
.actions button svg { width: 17px; height: 17px; }
.actions button:hover { background: var(--hover); color: var(--fg); }
.actions button.on { color: var(--accent); }
.actions button[data-tip]:hover::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); white-space: nowrap;
  font-size: .72rem; padding: 4px 8px; border-radius: 6px; background: var(--fg); color: var(--bg); pointer-events: none; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.confirm { display: flex; gap: 8px; margin-top: 10px; }
.reminder-form { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; max-width: 360px; }
.reminder-form input { padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.confirm button { padding: 8px 16px; border-radius: 999px; background: var(--fg); color: var(--bg); }
.confirm button.ghost { background: var(--bubble); color: var(--fg); }

/* "thinking": a shimmer line instead of words */
.thinking { width: 120px; height: 12px; border-radius: 6px; margin: 8px 0;
            background: linear-gradient(90deg, var(--bubble) 0%, var(--hover) 20%, rgba(74, 125, 255, .35) 40%, var(--hover) 60%, var(--bubble) 100%);
            background-size: 300% 100%; animation: shimmer 1.4s linear infinite; }
.thinking + .thinking { width: 200px; animation-delay: .15s; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -200% 0; } }
.streaming > :last-child::after { content: ""; display: inline-block; width: .55em; height: .55em; margin-left: .25em; border-radius: 50%; background: var(--fg); vertical-align: middle; animation: breathe 1s var(--ease) infinite; }

/* answers formatted like chat apps */
.msg.bot .body h2 { font-size: 1.22rem; font-weight: 650; margin: 1.2em 0 .5em; letter-spacing: -.01em; }
.msg.bot .body h3 { font-size: 1.08rem; font-weight: 650; margin: 1.1em 0 .4em; }
.msg.bot .body h4 { font-size: 1rem; font-weight: 650; margin: .9em 0 .3em; }
.msg.bot .body > :first-child { margin-top: 0; }
.msg.bot .body p { margin: 0 0 .9em; }
.msg.bot .body ul, .msg.bot .body ol { margin: 0 0 .9em; padding-left: 1.5em; }
.msg.bot .body li { margin: .35em 0; padding-left: .15em; }
.msg.bot .body li > ul, .msg.bot .body li > ol { margin: .3em 0 0; }
.msg.bot .body strong { font-weight: 650; }
.msg.bot .body hr { border: 0; border-top: 1px solid var(--line); margin: 1.4em 0; }
.msg.bot .body blockquote { margin: 0 0 .9em; padding: .1em 0 .1em 1em; border-left: 3px solid var(--accent); color: var(--muted); }
.msg.bot .body code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .87em; background: var(--bubble); padding: .15em .4em; border-radius: 6px; }
.msg.bot .body .code { position: relative; margin: 0 0 .9em; }
.msg.bot .body pre { background: var(--surface); border: 1px solid var(--line); padding: 14px 16px; border-radius: 14px; overflow-x: auto; margin: 0; }
.msg.bot .body pre code { background: none; padding: 0; }
.code-copy { position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: var(--faint); background: var(--bg); border: 1px solid var(--line); }
.code-copy svg { width: 15px; height: 15px; }
.msg.bot .body a { color: var(--fg); text-decoration: underline; text-decoration-color: var(--faint); }
.msg.bot .body .table { overflow-x: auto; margin: 0 0 1em; border: 1px solid var(--line); border-radius: 12px; }
.msg.bot .body table { border-collapse: collapse; font-size: .92em; min-width: 100%; }
.msg.bot .body th, .msg.bot .body td { padding: 9px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.msg.bot .body tr:last-child td { border-bottom: 0; }
.msg.bot .body th { font-weight: 650; background: var(--surface); }

.to-bottom { position: absolute; left: 50%; bottom: 120px; translate: -50% 0; width: 38px; height: 38px; border-radius: 50%; background: var(--bg); color: var(--fg);
             border: 1px solid var(--line); box-shadow: var(--shadow); display: grid; place-items: center; z-index: 3; animation: pop .45s var(--spring); }
.to-bottom svg { width: 18px; height: 18px; }

/* composer */
.composer { position: relative; padding: 6px max(12px, calc((100% - 760px) / 2)) max(10px, env(safe-area-inset-bottom)); }
.bar { display: flex; align-items: flex-end; gap: 6px; border-radius: 28px; padding: 6px 6px 6px 8px; background: var(--bubble);
       transition: box-shadow .3s var(--ease), background .3s; }
.bar:focus-within { box-shadow: 0 0 0 1px var(--line), 0 6px 24px rgba(0, 0, 0, .08); background: var(--bg); }
.bar textarea { flex: 1; border: 0; outline: 0; resize: none; background: transparent; padding: 9px 0; max-height: 40vh; line-height: 1.45; }
.bar textarea::placeholder { color: var(--faint); }
.bar-actions { display: flex; gap: 4px; }
.round { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.round svg { width: 20px; height: 20px; }
.send { background: var(--fg); color: var(--bg); }
.send:disabled { background: var(--hover); color: var(--faint); cursor: default; transform: scale(.9); }
.send:not(:disabled) { animation: pop .4s var(--spring); }
.mic { color: var(--fg); touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.mic:hover { background: var(--hover); }
.mic.on { background: var(--accent); color: #fff; transform: scale(1.18); box-shadow: 0 0 0 calc(var(--level, 0) * 22px + 4px) rgba(59, 130, 246, .18); transition: transform .4s var(--spring), box-shadow .08s linear; }
.plus { color: var(--fg); transition: transform .45s var(--spring), background .2s; }
.plus:hover { background: var(--hover); }
.plus.open { transform: rotate(45deg); background: var(--hover); }
.state { margin: 6px 0 0; text-align: center; font-size: .75rem; color: var(--faint); min-height: 1.1em; }

.tools-menu { position: absolute; left: max(12px, calc((100% - 760px) / 2)); bottom: calc(100% - 2px); z-index: 5; min-width: 250px; padding: 10px;
              background: var(--glass); backdrop-filter: saturate(1.8) blur(24px); -webkit-backdrop-filter: saturate(1.8) blur(24px);
              border: 1px solid var(--line); border-radius: 28px; box-shadow: var(--shadow); transform-origin: bottom left; animation: menu-in .45s var(--spring); }
@keyframes menu-in { from { opacity: 0; transform: scale(.8) translateY(10px); } }
.tools-menu button { width: 100%; display: flex; align-items: center; gap: 16px; text-align: left; padding: 7px 18px 7px 8px; border-radius: 20px; font-size: 1.02rem; animation: rise .4s var(--ease) both; }
.tools-menu button:nth-child(2) { animation-delay: .03s; } .tools-menu button:nth-child(3) { animation-delay: .06s; } .tools-menu button:nth-child(4) { animation-delay: .09s; }
.tools-menu button:hover { background: var(--hover); }
.tools-menu b { font-weight: 500; }
.tool-icon { width: 48px; height: 48px; border-radius: 50%; background: var(--hover); display: grid; place-items: center; flex: none; }
.tool-icon svg { width: 22px; height: 22px; }

.screen-chip { display: flex; align-items: center; gap: 8px; font-size: .82rem; color: var(--muted); padding: 7px 8px 7px 12px; margin: 0 0 8px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); animation: rise .45s var(--ease); }
.screen-chip span:nth-child(2) { flex: 1; }
.screen-chip button { padding: 5px 12px; border-radius: 999px; background: var(--fg); color: var(--bg); font-size: .8rem; font-weight: 600; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); animation: breathe 1.2s var(--ease) infinite; box-shadow: 0 0 0 3px rgba(229, 72, 77, .2); }

/* voice: tap the mic, the input turns into a live waveform (bars stretch with your voice), tap stop to send */
.rec { align-items: center; padding: 6px; animation: rec-in .45s var(--spring); }
@keyframes rec-in { from { transform: scaleX(.92); opacity: 0; } }
.wave { flex: 1; height: 38px; display: flex; align-items: center; justify-content: flex-end; gap: 3px; overflow: hidden; padding: 0 6px;
        mask-image: linear-gradient(90deg, transparent, #000 18%); -webkit-mask-image: linear-gradient(90deg, transparent, #000 18%); }
.wave i { flex: none; width: 3px; height: 4px; border-radius: 2px; background: var(--fg); transition: height .09s linear; }
.wave.loading i { animation: wave-wait 1s var(--ease) infinite; animation-delay: calc(var(--n) * 30ms); }
@keyframes wave-wait { 0%, 100% { height: 4px; opacity: .35; } 50% { height: 16px; opacity: .9; } }
.rec .send { animation: none; }
.mic.on { background: var(--accent); color: #fff; }

/* left drawer (phones) and sidebar (computers) */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .28); z-index: 10; backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); animation: fade .3s var(--ease); }
.drawer { position: absolute; inset: 0 auto 0 0; width: min(320px, 84vw); background: var(--surface); display: flex; flex-direction: column;
          padding: max(10px, env(safe-area-inset-top)) 8px max(10px, env(safe-area-inset-bottom)); animation: slide .5s var(--ease); box-shadow: var(--shadow); }
@keyframes slide { from { transform: translateX(-100%); } }
.drawer-backdrop.leaving { animation: fade .25s var(--ease) reverse forwards; }
.drawer-backdrop.leaving .drawer { animation: slide .3s var(--ease) reverse forwards; }
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 8px 10px 12px; font-size: 1.05rem; }
.drawer-head img { width: 28px; height: 28px; border-radius: 8px; }
.search { margin: 8px 4px 4px; padding: 9px 12px; border-radius: 12px; border: 0; background: var(--hover); outline: 0; }
.section { margin: 14px 10px 4px; font-size: .76rem; color: var(--faint); font-weight: 600; letter-spacing: .02em; }
.threads { flex: 1; overflow-y: auto; min-height: 60px; }
.thread { display: flex; align-items: center; border-radius: 10px; animation: rise .4s var(--ease) both; }
.thread.current, .thread:hover { background: var(--hover); }
.thread-open { flex: 1; min-width: 0; display: flex; padding: 9px 10px; text-align: left; font-size: .93rem; }
.thread-open span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-delete { width: 34px; height: 34px; color: var(--faint); border-radius: 8px; display: grid; place-items: center; opacity: 0; transition: opacity .2s; }
.thread-delete svg { width: 16px; height: 16px; }
.thread:hover .thread-delete, .thread.current .thread-delete { opacity: 1; }
@media (pointer: coarse) { .thread-delete { opacity: .6; } }
.drawer-foot { border-top: 1px solid var(--line); padding-top: 6px; }
.row { width: 100%; display: flex; align-items: center; gap: 10px; text-align: left; padding: 11px 10px; border-radius: 10px; color: var(--fg); text-decoration: none; font-size: .93rem; }
.row:hover { background: var(--hover); }
.row svg { width: 18px; height: 18px; }
.row.strong { font-weight: 600; }
.row.danger { color: var(--danger); }
.row.hint { color: var(--faint); font-size: .85rem; margin: 0; }
.row-note { margin-left: auto; color: var(--faint); font-size: .78rem; }
.toggle { justify-content: space-between; }
.toggle span { display: flex; flex-direction: column; }

/* iOS-style switch */
.switch { appearance: none; -webkit-appearance: none; flex: none; width: 51px; height: 31px; border-radius: 16px; background: var(--hover); position: relative; cursor: pointer; transition: background .3s var(--ease); margin: 0; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .25); transition: transform .45s var(--spring); }
.switch:checked { background: #34c759; }
.switch:checked::after { transform: translateX(20px); }
.switch:active::after { width: 32px; }
.switch:checked:active::after { transform: translateX(15px); }

/* photo attach */
.attachment { position: relative; display: inline-block; margin: 0 0 8px 6px; animation: pop .45s var(--spring); }
.attachment img { width: 64px; height: 64px; object-fit: cover; border-radius: 14px; display: block; border: 1px solid var(--line); }
.attachment button { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; background: var(--fg); color: var(--bg); font-size: .7rem; }
.msg.user .photo { display: block; max-width: 240px; max-height: 240px; border-radius: 18px; margin: 0 0 6px auto; animation: bubble .5s var(--spring) both; }

/* account row in the drawer */
.account { gap: 12px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, var(--sky1), var(--sky2)); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .9rem; flex: none; }
.account-name { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.account-name small { color: var(--faint); font-size: .78rem; }

/* full-screen pages slide in from the right like iOS */
.page { position: fixed; inset: 0; background: var(--bg); z-index: 20; display: flex; flex-direction: column; overflow-y: auto; animation: push .5s var(--ease); }
@keyframes push { from { transform: translateX(100%); } }
.page.leaving { animation: push .35s var(--ease) reverse forwards; }
.page.onboarding { animation: rise .7s var(--ease); }
.page-body { width: min(580px, 100%); margin: 0 auto; padding: 0 16px max(24px, env(safe-area-inset-bottom)); }
.page-body.center { text-align: center; padding-top: max(8vh, env(safe-area-inset-top)); display: flex; flex-direction: column; gap: 14px; }
.page-body.center h2 { margin: 0; font-size: 1.4rem; line-height: 1.4; }
.group { background: var(--surface); border-radius: 16px; padding: 4px; }
@media (prefers-color-scheme: dark) { .page .group { background: var(--bubble); } }
.toggle small, .hint-text { color: var(--faint); font-size: .8rem; font-weight: 400; }
.pad { padding: 6px 10px 0; margin: 0; }
.field { display: flex; flex-direction: column; gap: 6px; padding: 10px; font-weight: 600; }
.field input { padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); font-weight: 400; }
.inline { display: flex; gap: 8px; margin-top: 4px; }
.inline input { flex: 1; min-width: 0; }
.pill { padding: 8px 16px; border-radius: 999px; background: var(--fg); color: var(--bg); font-weight: 600; font-size: .9rem; flex: none; }
.pill.done { background: var(--bubble); color: var(--faint); }
.pill.ghost { background: var(--hover); color: var(--fg); }
.perm-list { display: flex; flex-direction: column; gap: 8px; text-align: left; margin: 8px 0; }
.perm { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 16px; animation: rise .6s var(--ease) both; }
.perm:nth-child(2) { animation-delay: .07s; } .perm:nth-child(3) { animation-delay: .14s; } .perm:nth-child(4) { animation-delay: .21s; }
.perm-icon { font-size: 1.4rem; }
.perm > span:nth-child(2) { flex: 1; display: flex; flex-direction: column; }
.perm small { color: var(--faint); font-size: .82rem; }
.family-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; font-size: .9rem; }
.family-row span { flex: 1; }
.family-row small { color: var(--faint); }
.family-row .pill { padding: 6px 12px; font-size: .78rem; }

/* notification list and a single notification */
.segmented { position: relative; display: grid; grid-template-columns: 1fr 1fr; padding: 3px; margin: 6px 0 14px; border-radius: 12px; background: var(--bubble); }
.segmented button { position: relative; z-index: 1; padding: 8px; font-size: .9rem; font-weight: 600; color: var(--muted); transition: color .3s; }
.segmented button.on { color: var(--fg); }
.segmented-thumb { position: absolute; top: 3px; bottom: 3px; left: 3px; width: calc(50% - 3px); border-radius: 9px; background: var(--bg); box-shadow: 0 2px 8px rgba(0, 0, 0, .1); transition: transform .5s var(--spring); }
.segmented.second .segmented-thumb { transform: translateX(100%); }
.inbox-list { display: flex; flex-direction: column; gap: 8px; }
.notice-row { display: flex; gap: 12px; width: 100%; text-align: left; padding: 13px 14px; border-radius: 16px; background: var(--surface); animation: rise .45s var(--ease) both; }
.notice-row .avatar { width: 38px; height: 38px; }
.notice-row div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.notice-row b { font-size: .92rem; display: flex; justify-content: space-between; gap: 8px; }
.notice-row b small { color: var(--faint); font-weight: 400; font-size: .76rem; flex: none; }
.notice-row p { margin: 2px 0 0; color: var(--muted); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.notice-row.unread { background: rgba(59, 130, 246, .08); }
.notice-row.unread b::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); align-self: center; margin-right: -2px; order: -1; flex: none; }
.empty-list { text-align: center; color: var(--faint); padding: 40px 0; }
.notice-card { margin-top: 10px; padding: 22px; border-radius: 22px; background: var(--surface); animation: rise .55s var(--ease) both; }
.notice-from { display: flex; align-items: center; gap: 10px; font-weight: 650; margin-bottom: 12px; }
.notice-text { font-size: 1.2rem; line-height: 1.6; margin: 0 0 12px; white-space: pre-wrap; word-break: break-word; }
.reply { display: flex; gap: 8px; align-items: flex-end; margin-top: 14px; padding: 6px 6px 6px 16px; border-radius: 24px; background: var(--bubble); animation: rise .6s .1s var(--ease) both; }
.reply textarea { flex: 1; border: 0; outline: 0; resize: none; background: transparent; padding: 8px 0; }

/* incoming family news */
.toast { position: fixed; left: 50%; top: max(12px, env(safe-area-inset-top)); translate: -50% 0; z-index: 30; width: min(440px, calc(100% - 24px)); cursor: pointer;
         background: var(--glass); color: var(--fg); backdrop-filter: saturate(1.8) blur(24px); -webkit-backdrop-filter: saturate(1.8) blur(24px);
         border: 1px solid var(--line); padding: 12px 16px; border-radius: 20px; box-shadow: var(--shadow); animation: drop .6s var(--spring); }
.toast div + div { margin-top: 6px; }
.toast small { display: block; color: var(--faint); font-size: .76rem; }
.toast.leaving { animation: drop .3s var(--ease) reverse forwards; }
@keyframes drop { from { transform: translateY(-140%) scale(.9); opacity: 0; } }

/* interests and the owner's admin page */
.interest-list { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 10px 10px; }
.interest { display: inline-flex; align-items: center; gap: 6px; padding: 6px 6px 6px 12px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); font-size: .88rem; animation: pop .4s var(--spring); }
.interest button { width: 20px; height: 20px; border-radius: 50%; font-size: .65rem; color: var(--faint); background: var(--hover); }
.family-cards { display: flex; flex-direction: column; gap: 8px; }
.family-card { display: grid; grid-template-columns: 40px 1fr 12px; align-items: center; gap: 12px; padding: 14px; border-radius: 18px; background: var(--surface); animation: rise .45s var(--ease) both; }
.family-card .avatar { width: 40px; height: 40px; }
.family-card div:nth-child(2) { display: flex; flex-direction: column; min-width: 0; }
.family-card small { color: var(--faint); font-size: .78rem; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--hover); }
.status-dot.on { background: #34c759; box-shadow: 0 0 0 4px rgba(52, 199, 89, .18); }
.family-actions { grid-column: 1 / -1; display: flex; gap: 6px; }
.family-actions .pill { padding: 7px 12px; font-size: .8rem; }
.invite { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 8px; padding: 10px; animation: pop .45s var(--spring); }
.invite b { font-size: 1.5rem; letter-spacing: .12em; font-family: ui-monospace, Consolas, monospace; }
.invite small { grid-column: 1 / -1; color: var(--faint); }
.invite .round { background: var(--hover); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 8px; }
.stat { padding: 12px; border-radius: 14px; background: var(--bg); display: flex; flex-direction: column; }
.stat b { font-size: 1.4rem; }
.stat small { color: var(--faint); font-size: .78rem; }
.stat.warn b { color: var(--danger); }
.log-list { display: flex; flex-direction: column; padding: 0 6px 6px; }
.log-row { display: flex; justify-content: space-between; gap: 10px; padding: 8px 4px; border-top: 1px solid var(--line); font-size: .86rem; }
.log-row:first-child { border-top: 0; }
.log-row small { color: var(--faint); text-align: right; }
.log-row.denied span { color: var(--danger); }

/* baduk board */
.board-body { display: flex; flex-direction: column; gap: 10px; }
.board-bar { display: flex; align-items: center; gap: 2px; }
.board-bar .spacer { flex: 1; }
.turn { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; background: var(--bubble); font-size: .9rem; }
.stone-dot { width: 16px; height: 16px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #666, #000 70%); transition: background .3s; }
.turn.white .stone-dot { background: radial-gradient(circle at 35% 30%, #fff, #d6d6d6 75%); box-shadow: inset 0 0 0 1px #aaa; }
.goban { width: 100%; max-width: 560px; margin: 0 auto; aspect-ratio: 1; border-radius: 10px; overflow: hidden; touch-action: manipulation;
         box-shadow: 0 12px 34px rgba(120, 80, 20, .28), inset 0 0 0 1px rgba(0, 0, 0, .08); animation: rise .6s var(--ease) both; }
.goban svg { width: 100%; height: 100%; display: block; cursor: pointer; }
.goban .stone { animation: place .35s var(--spring); transform-box: fill-box; transform-origin: center; }
@keyframes place { from { transform: scale(.3); opacity: 0; } }
.goban .mark { animation: pop .45s var(--spring); transform-box: fill-box; transform-origin: center; }
.board-result { padding: 14px 16px; border-radius: 16px; background: var(--surface); animation: rise .5s var(--ease) both; }
.board-result h3 { margin: 0 0 4px; font-size: 1.05rem; }
.winbar { height: 10px; border-radius: 5px; background: #e9e9e9; overflow: hidden; margin: 8px 0 12px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.winbar i { display: block; height: 100%; background: #111; transition: width .8s var(--ease); }
.cand { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); font-size: .92rem; }
.cand .num { width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .8rem; flex: none; }
.cand b { width: 42px; }
.cand small { color: var(--faint); margin-left: auto; text-align: right; }

/* computers: the drawer stays open as a sidebar */
@media (min-width: 1000px) {
  #sheet, #sheet[hidden] { display: block !important; position: fixed; inset: 0 auto 0 0; width: 280px; background: none; backdrop-filter: none; -webkit-backdrop-filter: none; animation: none; z-index: 4; }
  #sheet .drawer { position: absolute; width: 280px; box-shadow: none; border-right: 1px solid var(--line); animation: none; }
  #sheet.leaving, #sheet.leaving .drawer { animation: none; }
  .app { margin-left: 280px; }
  #menu-open { visibility: hidden; }
  .to-bottom { left: calc(50%); }
  .cards { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .page { left: 280px; }
}

@media (pointer: coarse) { .round { width: 44px; height: 44px; } .round svg { width: 22px; height: 22px; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
