/* Focus Sentinel — mobile PWA. Ported from the design prototype, but the app now
   FILLS the phone screen (no fake device frame) and respects the safe-area insets
   (notch / home indicator). Design tokens are kept identical to the desktop app. */
:root {
  --bg:#0a0b0d; --surf:#15161a; --surf2:#1b1c22; --bd:rgba(255,255,255,.08); --bd2:rgba(255,255,255,.15);
  --text:#e7e8ea; --mut:#83868d; --faint:#54565f;
  --acc:#8b7cff; --acc2:#a99dff; --green:#4ec98a; --red:#f06a5a;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* make every tappable element register cleanly on iOS (no 300ms delay, no tap that
   gets cancelled as a drag) */
button, .btn, .page, [data-action] { cursor: pointer; touch-action: manipulation; -webkit-user-select: none; user-select: none; }
html, body { margin: 0; height: 100%; }
html { background: #08090c; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", system-ui, sans-serif;
  background: radial-gradient(130% 90% at 50% 0%, #1a1c24 0%, #0c0d12 55%, #08090c 100%);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh; min-height: 100dvh;
  -webkit-user-select: none; user-select: none; overflow: hidden;
}
.mono { font-variant-numeric: tabular-nums; }

/* app shell fills the viewport via a flex COLUMN (NOT position:fixed). On iOS
   standalone a fixed/inset bottom floats above the real screen bottom, leaving a blank
   strip under the buttons — a height-based flex column anchors the bottom bar correctly.
   iPhone standalone: 100vh == real screen. iPad (Safari toolbar): use 100dvh so the bar
   isn't pushed off-screen. */
.app {
  height: 100vh;
  display: flex; flex-direction: column;
  padding: calc(var(--safe-t) + 14px) calc(var(--safe-r) + 22px) calc(var(--safe-b) + 16px) calc(var(--safe-l) + 22px);
  max-width: 520px; margin: 0 auto;
}
@media (min-width: 768px) { .app { height: 100dvh; } }
.fade { animation: fade .35s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
/* 집중 시작 — 버튼이 화면으로 펼쳐지는 컨테이너 변형.
   .morph는 화면 전체 크기의 보라 패널을 버튼 모양(clip-path inset…round)으로 잘라
   버튼 자리에 겹쳐 두고, .open에서 inset(0 round 0)으로 펼친다(테두리째 자라남).
   .done에서 보라가 걷히며 아래에 준비된 잠금 화면이 드러난다. */
.morph { position: fixed; inset: 0; z-index: 88; background: var(--acc);
  box-shadow: 0 8px 30px -10px rgba(139,124,255,.65);
  transition: clip-path .55s cubic-bezier(.25,.8,.25,1), -webkit-clip-path .55s cubic-bezier(.25,.8,.25,1), opacity .38s ease;
  will-change: clip-path, opacity; }
/* 펼침 목표값은 JS가 인라인으로 줌 — .open은 라벨 페이드만 담당 */
.morph.done { opacity: 0; }
.morph .morphlab { position: absolute; display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 800; color: #fff; transition: opacity .2s ease; }
.morph.open .morphlab { opacity: 0; }

/* the screen body fills the app shell so flex:1 sections (idlewrap / fwrap) center
   in the middle and .bottom sits at the bottom edge */
.content { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }

/* status row */
.top { display: flex; align-items: center; gap: 9px; margin-bottom: 22px; flex-shrink: 0; }
.top.center { justify-content: center; }   /* 세션 중엔 상태 표시를 가운데로 */
.top .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); transition: background .2s; }
.top .dot.green { background: var(--green); box-shadow: 0 0 9px var(--green); }
.top .dot.red { background: var(--red); box-shadow: 0 0 9px var(--red); }
.top .word { font-size: 13px; font-weight: 700; }
.top .word.green { color: var(--green); } .top .word.red { color: var(--red); } .top .word.mut { color: var(--mut); } .top .word.acc { color: var(--acc2); }
.top .dot.acc { background: var(--acc); box-shadow: 0 0 9px var(--acc); }
.top .link { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.top .link.live { background: var(--green); box-shadow: 0 0 7px var(--green); }
.top .gear { margin-left: auto; color: var(--mut); background: none; border: none; cursor: pointer; padding: 4px 2px; display: inline-flex; align-items: center; }
.top .gear:active { color: var(--text); }
.top .gear svg { display: block; }

/* 노트북 1차 경고 → 전체화면 사이렌 대신 빨간 테두리만 천천히 깜빡(소리·음성 없음) */
.redborder { position: fixed; inset: 0; z-index: 60; pointer-events: none;
  box-shadow: inset 0 0 0 6px var(--red), inset 0 0 46px 6px rgba(240,106,90,.5);
  animation: redPulse 1.7s ease-in-out infinite; }
@keyframes redPulse { 0%, 100% { opacity: .22; } 50% { opacity: 1; } }

/* ---------- idle ----------
   The work-type question + page chips sit centered in the middle of the screen;
   the goal input + start button live at the bottom. */
.idlewrap { display: flex; flex-direction: column; align-items: center; text-align: center; flex: 1; justify-content: center; min-height: 0; }
.ask { font-size: 30px; font-weight: 800; letter-spacing: -.4px; line-height: 1.25; margin-bottom: 34px; text-align: center; }
.flab { font-size: 11px; font-weight: 700; color: var(--faint); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 12px; }
.flab.center { text-align: center; }
.pages { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.page { font-size: 13.5px; font-weight: 700; padding: 10px 16px; border-radius: 999px; background: var(--surf); border: 1px solid var(--bd); color: var(--mut); cursor: pointer; transition: all .15s; }
.page.on { background: var(--acc); border-color: transparent; color: #fff; }
.page:active { transform: scale(.96); }
.taskbox { background: var(--surf); border: 1px solid var(--bd); border-radius: 16px; padding: 16px 17px; font-size: 16px; color: var(--text); width: 100%; font-family: inherit; outline: none; text-align: center; margin-bottom: 16px; -webkit-user-select: text; user-select: text; }
.taskbox::placeholder { color: var(--faint); }
.taskbox:focus { border-color: var(--bd2); }

/* ---------- active ---------- */
.fwrap { display: flex; flex-direction: column; align-items: center; flex: 1; justify-content: center; min-height: 0; }
.bigring { width: min(64vw, 240px); aspect-ratio: 1; border-radius: 50%; display: grid; place-items: center; position: relative; transition: background .5s; }
.bigring .inner { position: absolute; inset: 12px; border-radius: 50%; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.bigring .time { font-size: clamp(38px, 12vw, 48px); font-weight: 800; letter-spacing: -2px; line-height: 1; transition: color .3s; }
.bigring .tlab { font-size: 12px; color: var(--mut); margin-top: 5px; }
.fwrap .bigline { font-size: 22px; font-weight: 800; letter-spacing: -.5px; margin-top: 26px; transition: color .2s; text-align: center; }
.fwrap .sub { font-size: 13px; color: var(--mut); margin-top: 7px; text-align: center; max-width: 260px; line-height: 1.5; }
.taskchip { display: inline-flex; align-items: center; margin-top: 18px; padding: 8px 16px; background: var(--surf); border: 1px solid var(--bd); border-radius: 999px; font-size: 12.5px; font-weight: 700; color: var(--mut); }

.bottom { margin-top: auto; padding-top: 20px; flex-shrink: 0; }
.btn { width: 100%; border-radius: 16px; padding: 18px; font-size: 16px; font-weight: 800; font-family: inherit; cursor: pointer; border: none; transition: transform .12s, box-shadow .18s ease, filter .18s ease; }
.btn:active { transform: scale(.985); }
.btn.primary { background: var(--acc); color: #fff; box-shadow: 0 3px 10px -6px rgba(139,124,255,.45); }
/* 누르는 동안 살짝 들어가며 보랏빛 글로우 — 손을 떼면 톡 올라옴 */
.btn.primary.pressing { transform: scale(.955); box-shadow: 0 0 0 5px rgba(139,124,255,.16), 0 8px 22px -8px rgba(139,124,255,.6); filter: brightness(1.06); }
.btn.ghost { background: var(--surf); color: var(--text); border: 1px solid var(--bd2); }
.btn.danger { background: rgba(240,106,90,.12); color: var(--red); border: 1px solid rgba(240,106,90,.4); }

/* 버튼 주변 물 파동(일렁임) — 누르면 동심원이 퍼져나감, 손 뗄 때 큰 파동 한 번 */
.wave { position: fixed; width: 44px; height: 44px; border-radius: 50%; border: 2px solid rgba(139,124,255,.5); transform: translate(-50%,-50%) scale(.3); pointer-events: none; z-index: 95; will-change: transform, opacity; animation: waveOut 1.3s cubic-bezier(.18,.6,.2,1) forwards; }
.wave.big { border-width: 3px; border-color: rgba(165,153,255,.82); animation: waveBig .92s cubic-bezier(.15,.6,.2,1) forwards; }
@keyframes waveOut { 0% { opacity: 0; transform: translate(-50%,-50%) scale(.3); } 18% { opacity: .5; } 100% { opacity: 0; transform: translate(-50%,-50%) scale(6); } }
@keyframes waveBig { 0% { opacity: 0; transform: translate(-50%,-50%) scale(.4); } 14% { opacity: .72; } 100% { opacity: 0; transform: translate(-50%,-50%) scale(9); } }
/* idle: small text link under the start button (opens the iOS lock guide) */
.sublink { display: block; width: 100%; margin-top: 12px; background: none; border: none; color: var(--mut); font-size: 12.5px; font-weight: 700; font-family: inherit; cursor: pointer; padding: 6px; }
.sublink:active { opacity: .6; }

/* ---------- login screen ---------- */
.authwrap { flex: 1; justify-content: center; align-items: center; }
.authcard { width: 100%; max-width: 360px; display: flex; flex-direction: column; }
.authbrand { text-align: center; margin-bottom: 22px; }
.authlogo { font-size: 32px; line-height: 1; }
.authname { font-size: 22px; font-weight: 800; letter-spacing: -.4px; margin-top: 8px; }
.authsub { font-size: 13px; color: var(--mut); margin-top: 3px; }
.authtabs { display: flex; background: var(--surf); border: 1px solid var(--bd); border-radius: 12px; padding: 4px; margin-bottom: 18px; }
.authtab { flex: 1; padding: 11px; border-radius: 9px; background: none; border: none; color: var(--mut); font-size: 14px; font-weight: 800; font-family: inherit; cursor: pointer; transition: background .15s, color .15s; }
.authtab.on { background: var(--acc); color: #fff; }
.authlab { font-size: 11px; font-weight: 700; color: var(--faint); text-transform: uppercase; letter-spacing: .04em; margin: 0 2px 7px; }
.authin { background: var(--surf); border: 1px solid var(--bd); border-radius: 13px; padding: 15px 16px; font-size: 16px; color: var(--text); font-family: inherit; outline: none; margin-bottom: 14px; -webkit-user-select: text; user-select: text; }
.authin:focus { border-color: var(--bd2); }
.authin::placeholder { color: var(--faint); }
.autherr { background: rgba(240,106,90,.12); border: 1px solid rgba(240,106,90,.4); color: var(--red); font-size: 12.5px; font-weight: 600; border-radius: 11px; padding: 11px 13px; margin-bottom: 14px; line-height: 1.45; }
.authbtn { margin-top: 4px; }
.authlink { display: block; width: 100%; background: none; border: none; color: var(--acc2); font-size: 13px; font-weight: 700; font-family: inherit; cursor: pointer; padding: 14px 6px 2px; text-align: center; }
.authlink:active { opacity: .6; }
.authnote { font-size: 11.5px; color: var(--faint); line-height: 1.55; text-align: center; margin-top: 18px; padding: 0 2px; }
.authnote b { color: var(--mut); }
.authskip { display: block; width: 100%; background: none; border: none; color: var(--mut); font-size: 12.5px; font-weight: 700; font-family: inherit; cursor: pointer; padding: 16px 6px 2px; text-align: center; }
.authskip:active { opacity: .6; }

/* account row (settings sheet) */
.acctrow { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.acctinfo { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.acctemail { font-size: 15px; font-weight: 800; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.synctoggle { display: flex; align-items: flex-start; gap: 10px; margin-top: 12px; font-size: 12.5px; color: var(--mut); line-height: 1.5; cursor: pointer; }
.synctoggle input { width: 18px; height: 18px; margin-top: 1px; accent-color: var(--acc); flex-shrink: 0; }
.synctoggle b { color: var(--text); font-weight: 700; }

/* ---------- lock screen ---------- */
.lockbar { align-self: center; display: inline-flex; align-items: center; gap: 7px; flex-shrink: 0; margin-bottom: 14px;
  font-size: 12.5px; font-weight: 700; color: var(--mut); background: var(--surf); border: 1px solid var(--bd); border-radius: 999px; padding: 7px 14px; }
.lockbar .lk { font-size: 13px; }
.lockbar.pause { color: var(--acc2); background: rgba(139,124,255,.12); border-color: transparent; }
.lockbar .lkhint { color: var(--acc2); text-decoration: underline; text-underline-offset: 2px; margin-left: 3px; cursor: pointer; }
.bottom.lockbtns { display: flex; flex-direction: column; gap: 10px; }

/* ---------- iOS lock guide (in the settings sheet) ---------- */
.guide { display: flex; flex-direction: column; gap: 9px; margin-top: 2px; }
.gi { display: flex; gap: 11px; background: var(--surf2); border: 1px solid var(--bd); border-radius: 12px; padding: 12px 13px; font-size: 12.5px; line-height: 1.55; color: var(--text); }
.gi b { font-weight: 800; }
.gn { flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%; background: var(--acc); color: #fff; font-size: 12px; font-weight: 800; display: grid; place-items: center; }

/* ---------- pause sheet (− N분 + stepper) ---------- */
.stepper { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 10px 0 18px; }
.stepbtn { width: 66px; height: 66px; border-radius: 18px; background: var(--surf2); border: 1px solid var(--bd2); color: var(--text);
  font-size: 30px; font-weight: 700; font-family: inherit; cursor: pointer; display: grid; place-items: center; line-height: 1; flex-shrink: 0; }
.stepbtn:active { transform: scale(.94); background: var(--surf); }
.stepval { flex: 1; display: flex; align-items: baseline; justify-content: center; gap: 6px; }
.stepval #pmval { font-size: 58px; font-weight: 800; letter-spacing: -2px; font-variant-numeric: tabular-nums; line-height: 1; }
.stepunit { font-size: 20px; font-weight: 700; color: var(--mut); }

/* ---------- siren overlay ---------- */
.siren { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  padding: calc(var(--safe-t) + 40px) 34px calc(var(--safe-b) + 40px);
  background: radial-gradient(120% 100% at 50% 38%, #d8261b 0%, #a8170f 46%, #6f0f0a 100%); animation: sirenIn .3s ease; }
@keyframes sirenIn { from { opacity: 0; } to { opacity: 1; } }
.siren .rings { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.siren .rings span { position: absolute; width: 170px; height: 170px; border-radius: 50%; border: 1.5px solid rgba(255,255,255,.5); animation: sonar 3.4s ease-out infinite; }
.siren .rings span:nth-child(2){ animation-delay: 1.13s; } .siren .rings span:nth-child(3){ animation-delay: 2.26s; }
@keyframes sonar { 0%{ transform: scale(.4); opacity:.5;} 70%{opacity:.12;} 100%{ transform: scale(5.4); opacity:0;} }
.siren .mark { width: 96px; height: 96px; border-radius: 50%; background: rgba(255,255,255,.1); box-shadow: inset 0 0 0 3px rgba(255,255,255,.85); display: grid; place-items: center; position: relative; z-index: 1; margin-bottom: 24px; animation: throb 1.1s ease-in-out infinite; }
@keyframes throb { 0%,100%{transform:scale(1);} 50%{transform:scale(1.07);} }
.siren .mark .ex { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.siren .mark .bar { width: 9px; height: 32px; border-radius: 5px; background: #fff; }
.siren .mark .pt { width: 9px; height: 9px; border-radius: 50%; background: #fff; }
.siren h2 { color: #fff; font-size: 34px; font-weight: 800; letter-spacing: -1px; margin: 0 0 10px; z-index: 1; }
.siren p { color: rgba(255,255,255,.95); font-size: 15px; font-weight: 600; z-index: 1; margin: 0; max-width: 280px; line-height: 1.5; }
.siren .meta { color: rgba(255,255,255,.72); font-size: 12px; margin-top: 12px; z-index: 1; }
.siren .dismiss { margin-top: 30px; background: #fff; color: #b3140d; border: none; border-radius: 15px; padding: 17px 40px; font-size: 16px; font-weight: 800; font-family: inherit; z-index: 1; cursor: pointer; }
.siren .dismiss:active { transform: scale(.97); }

/* ---------- sheet (settings) ---------- */
.scrim { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.5); animation: sirenIn .25s ease; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 61; background: var(--surf); border-radius: 22px 22px 0 0;
  border-top: 1px solid var(--bd); padding: 10px 22px calc(var(--safe-b) + 34px); max-width: 520px; margin: 0 auto;
  animation: sheetUp .3s cubic-bezier(.2,.8,.3,1);
  /* the sheet can be taller than the screen → it scrolls internally on iOS.
     -webkit-overflow-scrolling + overscroll-behavior make the touch scroll reliable
     and stop it from rubber-banding the locked page behind it. */
  max-height: 88dvh; max-height: 88vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain; touch-action: pan-y; }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
/* grab handle — also the drag affordance (pull the sheet down to dismiss) */
.sheet .grab { width: 44px; height: 5px; border-radius: 99px; background: var(--bd2); margin: 2px auto 14px; }
.sheet h3 { font-size: 18px; font-weight: 800; margin: 2px 0 14px; }
.sheet .sec { font-size: 11px; font-weight: 700; color: var(--faint); text-transform: uppercase; letter-spacing: .05em; margin: 18px 0 9px; display: flex; align-items: center; gap: 7px; }
.sheet .sec::before { content:""; width: 6px; height: 6px; border-radius: 50%; background: var(--acc); box-shadow: 0 0 7px var(--acc); }
.sheet .sd { font-size: 12px; color: var(--faint); line-height: 1.55; margin-bottom: 12px; }
.sheet .row { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.sheet input { flex: 1; background: var(--surf2); border: 1px solid var(--bd); border-radius: 12px; padding: 13px 14px; font-size: 15px; color: var(--text); font-family: inherit; outline: none; -webkit-user-select: text; user-select: text; }
.sheet input:focus { border-color: var(--bd2); }
.sheet .mini { padding: 13px 16px; border-radius: 12px; font-size: 13px; font-weight: 800; border: none; font-family: inherit; cursor: pointer; white-space: nowrap; }
.sheet .mini.on { background: var(--acc); color: #fff; }
.sheet .mini.off { background: var(--surf2); color: var(--text); border: 1px solid var(--bd2); }
.connpill { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 700; padding: 7px 12px; border-radius: 999px; }
.connpill.on { color: var(--green); background: rgba(78,201,138,.12); }
.connpill.off { color: var(--mut); background: var(--surf2); }
.connpill .d { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.connpill.on .d { box-shadow: 0 0 7px var(--green); }

/* toast pill — TOP banner (the bottom is reserved for the action buttons, so a
   bottom toast overlapped them). Slides in just under the notch, centered. */
.toast { position: fixed; left: 50%; transform: translateX(-50%); top: calc(var(--safe-t) + 12px); z-index: 80;
  box-shadow: 0 8px 24px -8px rgba(0,0,0,.6); animation: sirenIn .2s ease; }

/* ---------- in-app dialog (e.g. "new work area") — replaces the native prompt ---------- */
.dialog { position: fixed; left: 50%; top: 42%; transform: translate(-50%, -50%); z-index: 61; width: min(86vw, 360px);
  background: var(--surf); border: 1px solid var(--bd2); border-radius: 20px; padding: 22px; animation: dlgIn .2s ease; }
@keyframes dlgIn { from { opacity: 0; transform: translate(-50%, -46%); } to { opacity: 1; transform: translate(-50%, -50%); } }
.dialog h3 { font-size: 17px; font-weight: 800; margin: 0 0 14px; }
.dlgin { width: 100%; background: var(--surf2); border: 1px solid var(--bd); border-radius: 12px; padding: 14px; font-size: 16px; color: var(--text); font-family: inherit; outline: none; -webkit-user-select: text; user-select: text; }
.dlgin:focus { border-color: var(--bd2); }
.dlgrow { display: flex; gap: 10px; margin-top: 16px; }
.dlgbtn { flex: 1; padding: 14px; border-radius: 12px; font-size: 15px; font-weight: 800; font-family: inherit; cursor: pointer; border: none; }
.dlgbtn.ghost { background: var(--surf2); color: var(--text); border: 1px solid var(--bd2); }
.dlgbtn.primary { background: var(--acc); color: #fff; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; } }
