/* Colors. Light is a soft grey (#cccccc), dark a soft charcoal (#333333);
   the accent is the orange of Tomo's icon. */
:root {
  --bg: #cccccc;
  --surface: #d9d9d9;     /* cards, the message box, your messages */
  --pressed: #c2c2c2;
  --raised: #ececec;      /* the picked option in a segmented control */
  --text: #161616;
  --muted: #555555;
  --hairline: rgba(0, 0, 0, .09);
  --accent: #c2410c;
  --accent-text: #ffffff;
  --notice: #9b1c1c;      /* errors */
  --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 4px 16px rgba(0, 0, 0, .06);
  --header: rgba(204, 204, 204, .82);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #333333;
    --surface: #3f3f3f;
    --pressed: #4a4a4a;
    --raised: #5a5a5a;
    --text: #ededed;
    --muted: #a8a8a8;
    --hairline: rgba(255, 255, 255, .08);
    --accent: #f97316;
    --accent-text: #1a1a1a;
    --notice: #fca5a5;
    --shadow: 0 1px 2px rgba(0, 0, 0, .2), 0 4px 16px rgba(0, 0, 0, .18);
    --header: rgba(51, 51, 51, .82);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #333333;
  --surface: #3f3f3f;
  --pressed: #4a4a4a;
  --raised: #5a5a5a;
  --text: #ededed;
  --muted: #a8a8a8;
  --hairline: rgba(255, 255, 255, .08);
  --accent: #f97316;
  --accent-text: #1a1a1a;
  --notice: #fca5a5;
  --shadow: 0 1px 2px rgba(0, 0, 0, .2), 0 4px 16px rgba(0, 0, 0, .18);
  --header: rgba(51, 51, 51, .82);
  color-scheme: dark;
}

/* Mobile first: the base rules are for a phone held upright; wider screens
   get more room under the min-width queries. Padding uses the safe-area
   insets, since the installed app runs full screen around notches.
   Fonts are the device's own (system-ui), so Tomo looks native. */

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; } /* even on elements whose class sets display */
html, body { height: 100%; margin: 0; }
body {
  display: flex;
  flex-direction: column;
  height: 100dvh; /* the visible area, also while the keyboard is open */
  padding: 0 env(safe-area-inset-right) 0 env(safe-area-inset-left);
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Header: back/menu, title in the middle, action */
.top {
  position: sticky;
  top: 0;
  z-index: 1;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  padding: calc(6px + env(safe-area-inset-top)) 8px 6px;
  background: var(--header);
  -webkit-backdrop-filter: saturate(1.6) blur(16px);
  backdrop-filter: saturate(1.6) blur(16px);
  border-bottom: 1px solid var(--hairline);
}
.brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -.01em;
  text-decoration: none;
}
.brand img { width: 24px; height: 24px; border-radius: 6px; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px; /* big enough for a thumb */
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background-color .15s;
}
.icon-btn:active { background: var(--pressed); }
.icon-btn svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Conversation */
.log {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 16px 16px 8px;
}
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin-top: 22dvh;
  color: var(--muted);
  text-align: center;
}
.empty img { width: 72px; height: 72px; border-radius: 18px; box-shadow: var(--shadow); }
.empty p { margin: 0; font-size: 20px; font-weight: 500; letter-spacing: -.01em; color: var(--text); }
.msg {
  margin: 0 0 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg.user {
  width: fit-content;
  max-width: 82%;
  margin-left: auto;
  padding: 9px 14px;
  border-radius: 20px 20px 6px 20px;
  background: var(--surface);
}
.msg.assistant { line-height: 1.6; }
.msg.pending { color: var(--muted); }
.msg.tool { margin: -4px 0 12px; color: var(--muted); font-size: 13px; }
.msg.tool::before { content: "• "; color: var(--accent); }
.msg.notice { color: var(--notice); font-size: 14px; }

/* Message box: one rounded field with the send button inside */
.composer {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 6px 12px calc(10px + env(safe-area-inset-bottom));
}
.composer-box {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  padding: 4px 4px 4px 16px;
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.composer-box:focus-within { box-shadow: var(--shadow), 0 0 0 1.5px var(--accent); }
.composer textarea {
  flex: 1;
  resize: none;
  max-height: 35dvh;
  min-height: 40px;
  padding: 8px 0;
  border: 0;
  background: transparent;
  font-size: 16px; /* 16px: phones don't zoom in on focus */
}
.composer textarea:focus { outline: none; }
.composer textarea::placeholder { color: var(--muted); }
.send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  cursor: pointer;
  transition: transform .1s, opacity .15s;
}
.send:active { transform: scale(.92); }
.send svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.25; stroke-linecap: round; stroke-linejoin: round; }

/* Lists and cards (chats, settings) */
.page-title { font-size: 30px; font-weight: 700; letter-spacing: -.02em; margin: 4px 4px 16px; }
.chat-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-radius: 16px;
  background: var(--surface);
  overflow: hidden;
}
.chat-list:empty { display: none; }
.chat-list .empty { margin: 0; padding: 32px 16px; }
.chat-list li + li a { border-top: 1px solid var(--hairline); }
.chat-list a {
  display: flex;
  gap: 12px;
  align-items: baseline;
  min-height: 52px;
  padding: 14px 16px;
  color: var(--text);
  text-decoration: none;
  transition: background-color .15s;
}
.chat-list a:active { background: var(--pressed); }
.chat-list span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-list time { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }

.group-title {
  margin: 24px 16px 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.group-title:first-child { margin-top: 8px; }
.card { display: flex; flex-direction: column; gap: 14px; padding: 16px; border-radius: 16px; background: var(--surface); }
.card .muted { margin: 0; }
.muted { display: block; color: var(--muted); font-size: 15px; margin: 0 0 14px; }
.footnote { margin: 10px 16px 0; color: var(--muted); font-size: 13px; }
.row { display: flex; flex-direction: column; gap: 8px; }
.btn {
  width: 100%;
  min-height: 48px;
  padding: 10px 20px;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.secondary { background: var(--pressed); color: var(--text); }

/* System / Light / Dark */
.segmented { display: flex; padding: 3px; border-radius: 12px; background: var(--pressed); }
.segmented button {
  flex: 1;
  min-height: 38px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}
.segmented [aria-checked="true"] { background: var(--raised); box-shadow: var(--shadow); }

/* On/off switch */
.switch-row { display: flex; gap: 16px; align-items: center; justify-content: space-between; cursor: pointer; }
.switch-row .label { display: block; font-weight: 500; margin-bottom: 2px; }
.switch-row .muted { margin: 0; }
.switch {
  appearance: none;
  flex: none;
  position: relative;
  width: 52px;
  height: 32px;
  margin: 0;
  border-radius: 16px;
  background: var(--pressed);
  cursor: pointer;
  transition: background-color .2s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  transition: transform .2s;
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(20px); }
.switch:disabled { opacity: .45; }

/* Login: icon, name, one box */
body.login { align-items: center; justify-content: center; padding: 16px; }
.login-form { width: 100%; max-width: 380px; margin-bottom: 10dvh; text-align: center; }
.login-icon { display: block; width: 192px; height: 192px; margin: 0 auto; border-radius: 42px; box-shadow: var(--shadow); }
.login-name { margin: 20px 0 32px; font-size: 28px; font-weight: 600; letter-spacing: -.02em; }
.password-box { position: relative; }
.login-form .password-box input {
  width: 100%;
  min-height: 52px;
  padding: 12px 52px 12px 20px; /* room on the right for the eye button */
  border: 0;
  border-radius: 26px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.login-form input:focus { outline: none; box-shadow: var(--shadow), 0 0 0 1.5px var(--accent); }
.reveal {
  position: absolute;
  top: 50%;
  right: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transform: translateY(-50%);
}
.reveal:active { background: var(--pressed); }
.reveal svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.reveal .eye-off, .reveal[aria-pressed="true"] .eye { display: none; }
.reveal[aria-pressed="true"] .eye-off { display: block; }
.login-form .password-box input:placeholder-shown { padding-left: 52px; text-align: center; } /* even sides: centered */
.login-form input::placeholder { color: var(--muted); }
.login-form .login-btn { width: 100%; min-height: 52px; margin-top: 12px; border-radius: 26px; }
.login-wrong { color: var(--notice); margin: 14px 0 0; font-size: 15px; }

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

/* Mouse and trackpad: hover feedback */
@media (hover: hover) {
  .icon-btn:hover, .chat-list a:hover { background: var(--pressed); }
  .send:hover, .btn:hover { opacity: .9; }
}

/* Tablets and computers */
@media (min-width: 640px) {
  .top { padding-left: 16px; padding-right: 16px; }
  .log { padding: 24px 24px 8px; }
  .composer { padding: 6px 24px 20px; }
  .row { flex-direction: row; }
  .btn { width: auto; min-height: 42px; }
}

/* Password card: the passphrase with Show/Copy, then a box to change it */
.secret { display: flex; align-items: center; gap: 4px; min-height: 40px; }
.secret-value { flex: 1; min-width: 0; overflow-wrap: anywhere; color: var(--muted); letter-spacing: .1em; }
.secret-value.shown { color: var(--text); letter-spacing: 0; font-weight: 500; user-select: all; }
.text-btn {
  flex: none;
  min-height: 40px;
  padding: 0 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}
.text-btn:active { background: var(--pressed); }
.field-row { display: flex; flex-direction: column; gap: 8px; }
.field {
  width: 100%;
  min-height: 48px;
  padding: 10px 16px;
  border: 0;
  border-radius: 14px;
  background: var(--pressed);
  font-size: 16px; /* phones don't zoom in on focus */
}
.field::placeholder { color: var(--muted); }
.field:focus { outline: none; box-shadow: 0 0 0 1.5px var(--accent); }
@media (min-width: 640px) {
  .field-row { flex-direction: row; }
}

/* Share screen: the shared text, then where it goes */
.share-text { display: block; min-height: 96px; max-height: 30dvh; margin-bottom: 16px; resize: none; line-height: 1.45; }
.choices { margin-bottom: 8px; }
.chat-list button {
  display: flex;
  gap: 12px;
  align-items: center;
  width: 100%;
  min-height: 52px;
  padding: 14px 16px;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background-color .15s;
}
.chat-list button:active { background: var(--pressed); }
.chat-list li + li button { border-top: 1px solid var(--hairline); }
.choices a, .choices button { align-items: center; font-weight: 500; }
.choices svg { flex: none; width: 22px; height: 22px; fill: none; stroke: var(--accent); stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.done-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
}
.done-mark svg { width: 36px; height: 36px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
a.done-btn { display: inline-flex; align-items: center; justify-content: center; width: auto; min-width: 160px; text-decoration: none; }
@media (hover: hover) {
  .chat-list button:hover { background: var(--pressed); }
}

/* Chats | Notes tabs (the segmented control, as links) */
.tabs { margin: 0 0 16px; }
.segmented a {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  border-radius: 9px;
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
}
.segmented a[aria-current="page"] { background: var(--raised); box-shadow: var(--shadow); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }

/* Notes */
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding: 0 14px;
  border-radius: 14px;
  background: var(--surface);
}
.search:focus-within { box-shadow: 0 0 0 1.5px var(--accent); }
.search svg { flex: none; width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.search input { flex: 1; min-width: 0; min-height: 44px; border: 0; background: transparent; font-size: 16px; }
.search input:focus { outline: none; }
.search input::placeholder { color: var(--muted); }

.note-list { list-style: none; margin: 0 0 8px; padding: 0; border-radius: 16px; background: var(--surface); overflow: hidden; }
.note-list:empty { display: none; }
.note { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; }
.note + .note { border-top: 1px solid var(--hairline); }
.note-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.note-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; margin: 0; font-size: 13px; color: var(--muted); }
.note-meta time { font-variant-numeric: tabular-nums; }
.note-status.filed { color: var(--text); }
.note-status.filed::before { content: "✓ "; color: var(--accent); font-weight: 700; }
.note-status.failed { color: var(--notice); }

/* Waiting for your answer: on top, outlined in the accent */
#questions .note-list { background: transparent; overflow: visible; }
.note.attention { border: 1.5px solid var(--accent); border-radius: 16px; background: var(--surface); }
.note.attention + .note.attention { margin-top: 10px; border-top: 1.5px solid var(--accent); }
.badge {
  align-self: flex-start;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
}
.question { margin: 0; font-weight: 600; }
.question::before { content: "Tomo: "; color: var(--accent); }

.note-files { display: flex; flex-wrap: wrap; gap: 8px; }
.thumb img { display: block; width: 88px; height: 88px; object-fit: cover; border-radius: 10px; background: var(--pressed); }
.file-chip {
  display: inline-flex;
  flex-direction: column;
  max-width: 100%;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--pressed);
  color: var(--text);
  text-decoration: none;
}
.file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.file-size { color: var(--muted); font-size: 12px; }
.more { padding: 16px; color: var(--muted); text-align: center; font-size: 14px; }
#empty { margin-top: 12dvh; }

/* Adding a note: tool buttons in the message box, files waiting to be saved */
.tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.tool-btn:active { background: var(--pressed); }
.tool-btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }
.tool-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
#add .composer-box { padding-left: 4px; }
.pending { display: flex; gap: 8px; margin: 0 0 8px; padding: 0; list-style: none; overflow-x: auto; }
.pending-file {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
  max-width: 220px;
  padding: 4px 4px 4px 4px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.pending-file img { width: 36px; height: 36px; object-fit: cover; border-radius: 8px; }
.pending-file .file-name { padding-left: 4px; }
.remove { flex: none; width: 32px; height: 32px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); font-size: 20px; cursor: pointer; }
@media (hover: hover) {
  .tool-btn:hover { background: var(--pressed); }
}
