/*
 * jarvis webapp — 다크 테마.
 * jarvis/ui/widget.html:6-149 에서 이식했다. 색상 변수는 menubar.py:64 의
 * 배경색(#0b0f14)과 맞춰져 있어 위젯·웹앱 외관 일치가 공짜로 따라온다.
 */
:root {
  --bg: #0b0f14;
  --panel: #11161d;
  --border: #1e2733;
  --accent: #4fd1ff;
  --accent-dim: #1c5b73;
  --text: #e6edf3;
  --text-dim: #8b98a5;
  --danger: #ff6b6b;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", sans-serif;
  min-height: 100%;
}
#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 20px;
}
#header .title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--accent);
}
#header .sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}

#main {
  margin-top: 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#subscribeBtn {
  background: var(--accent);
  color: #061319;
  border: none;
  border-radius: 10px;
  padding: 14px 20px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
#subscribeBtn:disabled {
  opacity: 0.4;
  cursor: default;
}

#status {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-dim);
}
#status .row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
#status .row + .row {
  margin-top: 4px;
}
#status .value {
  color: var(--text);
}
#status .value.ok { color: var(--accent); }
#status .value.warn { color: var(--danger); }

#installHint {
  display: none;
  background: var(--panel);
  border: 1px solid var(--accent-dim);
  border-radius: 10px;
  padding: 14px;
  font-size: 13px;
  line-height: 1.6;
}
#installHint.visible { display: block; }
#installHint ol {
  margin: 8px 0 0;
  padding-left: 20px;
}
#installHint li + li { margin-top: 4px; }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* 설치 안내 보조 문구 — iOS 전용 안내임을 밝힌다 */
#installHint .hint-note {
  margin: 6px 0 0;
  font-size: 12px;
  opacity: 0.65;
}

/* ── 대화 UI ─────────────────────────────────────────────────────────
   대화가 주역이고 설정은 접힌다. 매일 여는 화면에서 구독 버튼이 매번
   보일 이유가 없다. 입력창은 화면 아래 고정 — 엄지로 닿는 자리다. */

/* 홈 화면 앱은 viewport-fit=cover 라 노치·상태바 아래까지 콘텐츠가 깔린다.
   safe-area 를 안 잡으면 헤더가 상태바와 겹치고 좌우가 화면 끝에 붙는다.
   가로는 기본 여백과 안전 영역 중 큰 쪽을 쓴다 — 세로 모드에서는 대개
   안전 영역이 0 이라 기본값이, 가로 모드에서는 노치 쪽이 이긴다. */
#app {
  display: flex; flex-direction: column;
  height: 100dvh;
  max-width: 480px; margin: 0 auto;
  padding:
    calc(env(safe-area-inset-top) + 12px)
    max(16px, env(safe-area-inset-right))
    0
    max(16px, env(safe-area-inset-left));
}
#header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex: 0 0 auto;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
button.ghost {
  background: transparent; border: 1px solid #24303d; color: #7d8b9a;
  border-radius: 999px; padding: 6px 14px; font-size: 13px; cursor: pointer;
}
button.ghost:hover { color: #cfd8e3; border-color: #35485c; }

#chat {
  flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column; gap: 10px;
  padding: 16px 0; min-height: 0;
}
.msg {
  max-width: 88%; padding: 10px 14px; border-radius: 16px;
  line-height: 1.5; font-size: 15px; white-space: pre-wrap; word-break: break-word;
}
.msg.user { align-self: flex-end; background: #1d4ed8; color: #fff; border-bottom-right-radius: 4px; }
.msg.jarvis { align-self: flex-start; background: #16202b; color: #dbe4ee; border-bottom-left-radius: 4px; }
.msg.error { align-self: flex-start; background: #3a1a1a; color: #ffb4b4; font-size: 14px; }
.msg .tools {
  display: block; margin-top: 6px; font-size: 12px; color: #6f8296;
}
.msg.pending { opacity: .55; }
.empty { color: #56657a; font-size: 14px; text-align: center; margin: auto 0; }

#composer {
  flex: 0 0 auto; display: flex; gap: 8px; align-items: flex-end;
  /* 홈 인디케이터(가로 막대)와 겹치지 않게. 없는 기기에서는 12px 로 떨어진다. */
  padding-bottom: calc(env(safe-area-inset-bottom) + 12px);
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
#input {
  flex: 1; resize: none; max-height: 140px;
  background: #121a23; color: #e6edf5; border: 1px solid #24303d;
  border-radius: 18px; padding: 11px 14px; font: inherit; font-size: 15px;
  line-height: 1.4;
}
#input:focus { outline: none; border-color: #3b82f6; }
#send {
  flex: 0 0 auto; width: 42px; height: 42px; border-radius: 50%;
  background: #1d4ed8; color: #fff; border: 0; font-size: 19px; cursor: pointer;
}
#send:disabled { background: #24303d; color: #56657a; cursor: default; }

#panel { flex: 0 0 auto; border-top: 1px solid #1b2530; padding-top: 14px; margin-top: 12px; }
#pending { font-size: 13px; color: #7d8b9a; }
#pending .item { padding: 3px 0; }
#pending .warn { color: #ffb4b4; }

/* ── 대화창 목록 ─────────────────────────────────────────────────────
   창은 대화의 단위일 뿐이다. 리마인더·캡처는 창에 매이지 않으므로
   목록은 "지금 무슨 얘기를 하는가"만 고른다. */

#header .title {
  flex: 1; text-align: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
button.ghost.small { padding: 4px 10px; font-size: 12px; }

#threadPanel {
  flex: 0 0 auto; padding: 12px 0;
  border-bottom: 1px solid var(--border);
  max-height: 52dvh; overflow-y: auto;
}
#threadList { display: flex; flex-direction: column; gap: 2px; }

.thread {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border-radius: 10px; cursor: pointer;
  color: var(--text-dim); font-size: 15px;
}
.thread:hover { background: var(--panel); }
.thread.active { background: var(--panel); color: var(--text); font-weight: 600; }
.thread .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread .count { font-size: 12px; color: #56657a; }
.thread .act {
  background: none; border: 0; color: #56657a; cursor: pointer;
  font-size: 15px; padding: 2px 6px; line-height: 1;
}
.thread .act:hover { color: var(--text); }
.thread.archived .name { text-decoration: line-through; opacity: .6; }

#newThreadForm { display: flex; gap: 6px; margin-top: 10px; }
#newThreadTitle {
  flex: 1; background: #121a23; color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 12px; font: inherit; font-size: 14px;
}
#newThreadTitle:focus { outline: none; border-color: var(--accent); }
#newThreadForm button {
  background: var(--accent-dim); color: var(--text); border: 0;
  border-radius: 10px; padding: 0 14px; font-size: 14px; cursor: pointer;
}
#showArchived { margin-top: 8px; }
