@font-face {
  font-family: 'Editors Note';
  src: url('/app/fonts/editors-note.woff2') format('woff2'),
       url('/app/fonts/editors-note.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --kw-red: #E31C23;
  --kw-red-dark: #B8141A;
  --ink: #111111;
  --ink-2: #2a2a2a;
  --muted: #6b6b6b;
  --muted-2: #8a8a8a;
  --line: #e6e6e6;
  --bg: #f5f5f6;
  --card: #ffffff;
  --ask-bg: #f0f0f2;
  --bot-bubble: #ffffff;
  --user-bubble: #E31C23;
  --focus-blue: #4a90e2;
  --radius: 16px;
  --radius-lg: 20px;
  --shadow: 0 2px 10px rgba(0,0,0,.06);
  --shadow-card: 0 1px 3px rgba(0,0,0,.04), 0 4px 12px rgba(0,0,0,.04);
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

/* Brand display font (Regular only — size up, don't fake-bold) */
.brand-display,
.app-header h1,
.home-greeting,
.home-headline,
.task-title {
  font-family: 'Editors Note', Georgia, 'Times New Roman', serif;
  font-weight: 400;
  font-synthesis: none;
}
.app-header h1 {
  font-size: 1.35rem;
  letter-spacing: -.01em;
}
.home-greeting {
  font-size: 1.15rem;
  letter-spacing: -.01em;
}
.home-headline {
  font-size: clamp(1.85rem, 4.5vw, 2.45rem);
  letter-spacing: -.02em;
}
.task-title {
  font-size: 1.05rem;
  letter-spacing: -.01em;
}


* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--ink);
  overflow-x: hidden;
}
body {
  display: flex; flex-direction: column;
  min-height: 100dvh;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* Header */
.app-header {
  background: var(--ink);
  color: #fff;
  padding: calc(12px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 12px max(16px, env(safe-area-inset-left, 0px));
  display: flex; align-items: center; gap: 10px;
  position: sticky; top: 0; z-index: 10;
  box-shadow: 0 2px 10px rgba(0,0,0,.2);
  min-height: calc(60px + env(safe-area-inset-top, 0px));
}
.app-header .mark {
  width: 36px; height: 36px; border-radius: 50%;
  background: #fff;
  display: block;
  object-fit: cover;
  flex: 0 0 auto;
}
.app-header .brand {
  min-width: 0;
  flex: 0 1 auto;
  overflow: hidden;
}
.app-header h1 {
  margin: 0; font-size: 1.05rem; font-weight: 700;
  letter-spacing: -.01em;
  white-space: nowrap;
}
.app-header .sub {
  margin: 2px 0 0; font-size: .75rem; color: #cfcfcf;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-header .spacer { flex: 1 1 auto; min-width: 8px; }
.app-header .header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}
.app-header button.linkish {
  background: transparent; border: 1px solid #444; color: #ddd;
  border-radius: 999px;
  padding: 10px 12px;
  min-height: 44px;
  font-size: .75rem;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  flex: 0 0 auto;
  line-height: 1.2;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.app-header button.linkish:hover { border-color: #888; color: #fff; }
.app-header button.linkish:focus-visible {
  outline: 2px solid var(--focus-blue); outline-offset: 2px;
}

main {
  flex: 1; display: flex; flex-direction: column;
  width: 100%; max-width: 760px; margin: 0 auto;
  padding: 12px 16px 0;
}

/* Auth panel */
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin: 24px auto;
  max-width: 420px;
  width: 100%;
}
.panel h2 { margin: 0 0 8px; font-size: 1.15rem; }
.panel p { margin: 0 0 14px; color: var(--muted); line-height: 1.45; font-size: .95rem; }

label { display: block; font-size: .8rem; font-weight: 600; margin: 0 0 6px; color: var(--ink-2); }
input[type="tel"], input[type="text"] {
  width: 100%; padding: 12px 14px; border-radius: 12px;
  border: 1px solid #d0d0d0; font-size: 1rem; outline: none;
  background: #fff; font-family: inherit;
}
input:focus { border-color: var(--focus-blue); box-shadow: 0 0 0 3px rgba(74,144,226,.2); }

.row { display: flex; gap: 8px; margin-top: 12px; }
.btn {
  appearance: none; border: 0; border-radius: 12px;
  background: var(--kw-red); color: #fff; font-weight: 700;
  padding: 12px 16px; font-size: .95rem; cursor: pointer;
  font-family: inherit;
}
.btn:hover { background: var(--kw-red-dark); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--focus-blue); outline-offset: 2px; }
.btn.secondary {
  background: #fff; color: var(--ink); border: 1px solid #d0d0d0;
}
.btn.secondary:hover { background: #f3f3f3; }
.err {
  margin-top: 10px; color: var(--kw-red); font-size: .88rem; min-height: 1.2em;
}
.hint { font-size: .78rem; color: var(--muted); margin-top: 8px; }

/* Home view */
#home-view {
  display: none;
  flex: 1;
  flex-direction: column;
  justify-content: center;
  padding: 28px 0 48px;
  min-height: 0;
}
#home-view.active { display: flex; }

.home-hero {
  text-align: center;
  margin-bottom: 28px;
}
.home-greeting {
  margin: 0 0 10px;
  font-size: .95rem;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: -.01em;
}
.home-headline {
  margin: 0;
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  font-weight: 700;
  letter-spacing: -.03em;
  color: var(--ink);
  line-height: 1.2;
}

/* Home ask box */
.home-ask {
  background: var(--ask-bg);
  border: 1.5px solid transparent;
  border-radius: var(--radius-lg);
  padding: 14px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 28px;
  transition: border-color .15s, box-shadow .15s;
}
.home-ask:focus-within {
  border-color: var(--focus-blue);
  box-shadow: 0 0 0 3px rgba(74,144,226,.15);
  background: #fff;
}
.home-ask textarea {
  width: 100%;
  border: 0;
  resize: none;
  outline: none;
  font: inherit;
  font-size: 1rem;
  line-height: 1.45;
  background: transparent;
  color: var(--ink);
  min-height: 72px;
  max-height: 160px;
  padding: 0;
}
.home-ask textarea::placeholder { color: #a0a0a5; }
.home-ask-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.home-ask-left { display: flex; gap: 4px; }

.icon-btn {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--muted);
  width: 36px; height: 36px;
  border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-family: inherit;
}
.icon-btn:hover { background: rgba(0,0,0,.06); color: var(--ink); }
.icon-btn:focus-visible { outline: 2px solid var(--focus-blue); outline-offset: 1px; }
.icon-btn.listening { color: var(--kw-red); background: rgba(227,28,35,.1); }

.send-circle {
  appearance: none;
  border: 0;
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex: 0 0 auto;
  transition: background .15s, opacity .15s;
}
.send-circle:hover { background: #333; }
.send-circle:disabled { opacity: .4; cursor: not-allowed; }
.send-circle:focus-visible { outline: 2px solid var(--focus-blue); outline-offset: 2px; }

/* Task cards */
.task-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.task-card {
  appearance: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-card);
  padding: 14px 14px 16px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: inherit;
  color: inherit;
  transition: border-color .15s, box-shadow .15s, transform .1s;
  min-height: 118px;
}
.task-card:hover {
  border-color: #d0d0d4;
  box-shadow: 0 4px 16px rgba(0,0,0,.08);
  transform: translateY(-1px);
}
.task-card:focus-visible {
  outline: 2px solid var(--focus-blue);
  outline-offset: 2px;
}
.task-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: #f0f0f2;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.15rem;
  margin-bottom: 4px;
}
.task-title {
  font-size: .9rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -.01em;
  line-height: 1.25;
}
.task-desc {
  font-size: .78rem;
  color: var(--muted);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Chat view */
#chat-view { display: none; flex: 1; flex-direction: column; min-height: 0; }
#chat-view.active { display: flex; }

#messages {
  flex: 1; overflow-y: auto; padding: 8px 4px 16px;
  display: flex; flex-direction: column; gap: 10px;
  min-height: 40vh;
}
.msg {
  max-width: 92%; padding: 10px 14px; border-radius: 16px;
  line-height: 1.45; font-size: .95rem; white-space: pre-wrap; word-break: break-word;
}
.msg.bot {
  align-self: flex-start;
  background: var(--bot-bubble);
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
}
.msg.user {
  align-self: flex-end;
  background: var(--user-bubble); color: #fff;
  border-bottom-right-radius: 6px;
}
.msg.bot a { color: var(--kw-red); font-weight: 600; text-decoration: underline; }
.msg .meta { display: block; margin-top: 6px; font-size: .7rem; color: var(--muted); }
.msg.user .meta { color: rgba(255,255,255,.75); }

.thinking {
  align-self: flex-start;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-radius: 16px; border-bottom-left-radius: 6px;
  background: #fff; border: 1px solid var(--line); color: var(--muted);
  font-size: .9rem;
}
.thinking .dots span {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--muted); margin-right: 3px; animation: blink 1.2s infinite;
}
.thinking .dots span:nth-child(2) { animation-delay: .2s; }
.thinking .dots span:nth-child(3) { animation-delay: .4s; }
@keyframes blink {
  0%, 80%, 100% { opacity: .25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

.composer {
  position: sticky; bottom: 0;
  background: linear-gradient(180deg, rgba(245,245,246,0), var(--bg) 28%);
  padding: 10px 0 calc(12px + env(safe-area-inset-bottom));
}
.composer-box {
  display: block;
  background: #fff; border: 1.5px solid var(--line); border-radius: 18px;
  padding: 8px 10px 8px 10px; box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s;
}
.composer-box:focus-within {
  border-color: var(--focus-blue);
  box-shadow: 0 0 0 3px rgba(74,144,226,.15);
}
.composer-main { display: flex; flex-direction: column; gap: 6px; }
.composer-row {
  display: flex; gap: 6px; align-items: flex-end;
}
.composer textarea {
  flex: 1; border: 0; resize: none; outline: none;
  font: inherit; font-size: 1rem; max-height: 140px;
  padding: 8px 4px; background: transparent;
}
.composer textarea::placeholder { color: #a0a0a5; }

.hidden { display: none !important; }

@media (max-width: 720px) {
  .task-grid { grid-template-columns: repeat(2, 1fr); }
  .home-hero { margin-bottom: 22px; }
  #home-view { padding: 24px 0 32px; }
}
@media (max-width: 480px) {
  .task-grid { grid-template-columns: 1fr; }
  .msg { max-width: 96%; }
  .panel { padding: 16px; margin: 16px auto; }
  main { padding: 8px 12px 0; }
  .home-headline { font-size: 1.7rem; }
  .task-card { min-height: 0; }
  #home-view { justify-content: flex-start; padding: 20px 0 32px; }
  .home-hero { margin-bottom: 18px; }
  .home-ask { margin-bottom: 18px; }
  .app-header { gap: 8px; }
  .app-header .mark { width: 32px; height: 32px; }
  .app-header .header-actions { gap: 6px; }
  .app-header button.linkish {
    padding: 10px 10px;
    font-size: .72rem;
    min-height: 44px;
  }
  .app-header .sub { font-size: .7rem; max-width: 42vw; }
}


/* Attachment thumbs */
.attach-thumbs {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 2px 0 4px;
}
.attach-thumbs.hidden { display: none !important; }
.attach-thumb {
  position: relative;
  width: 64px; height: 64px;
  border-radius: 10px;
  overflow: hidden;
  background: #e8e8ea;
  flex: 0 0 auto;
  border: 1px solid rgba(0,0,0,.06);
}
.attach-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.attach-thumb .rm {
  position: absolute; top: 3px; right: 3px;
  width: 20px; height: 20px;
  border: 0; border-radius: 50%;
  background: rgba(0,0,0,.65); color: #fff;
  font-size: 12px; line-height: 1;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0;
  font-family: inherit;
}
.attach-thumb .rm:hover { background: rgba(0,0,0,.85); }
.attach-thumb .rm:focus-visible { outline: 2px solid var(--focus-blue); outline-offset: 1px; }
.attach-status {
  font-size: .78rem;
  color: var(--muted);
  min-height: 1.1em;
  padding: 0 2px;
}
.attach-status.err { color: var(--kw-red); }
.attach-status.hidden { display: none !important; }

/* Photos inside user bubbles */
.msg.user .msg-thumbs {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-bottom: 6px;
}
.msg.user .msg-thumbs:last-child { margin-bottom: 0; }
.msg.user .msg-thumbs img {
  width: 72px; height: 72px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.35);
  display: block;
}
.msg.user .msg-text { white-space: pre-wrap; }

/* Brand footer */
.app-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 18px 16px calc(16px + env(safe-area-inset-bottom));
  flex: 0 0 auto;
}
.app-footer img {
  width: 160px;
  height: auto;
  max-width: 42vw;
  opacity: .92;
  display: block;
}
.app-footer.compact {
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
}
.app-footer.compact img {
  width: 110px;
  opacity: .8;
}
.app-footer.hidden { display: none !important; }

@media (max-width: 480px) {
  .app-footer img { width: 130px; }
  .app-footer.compact img { width: 96px; }
  .attach-thumb { width: 56px; height: 56px; }
  .msg.user .msg-thumbs img { width: 64px; height: 64px; }
}
