/* Tina AI web — Claude.ai-inspired layout: dark sidebar, calm light main
   column, one centered reading width. System fonts, no external assets. */

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: #1a1a17;
  background: #f7f6f3;
}
.hidden { display: none !important; }

/* ── login ── */
.login { display: flex; align-items: center; justify-content: center; height: 100%; }
.login-card { text-align: center; padding: 2.5rem 3rem; background: #fff; border: 1px solid #e5e2da; border-radius: 16px; max-width: 26rem; }
.login-card h1 { margin: 0 0 .75rem; font-size: 1.6rem; }
.login-card p { color: #5d5a52; margin: 0 0 1.5rem; }
.login-error { color: #b3261e; }

/* ── app frame ── */
.app { display: flex; height: 100%; }
.sidebar {
  width: 280px; flex: none; display: flex; flex-direction: column;
  background: #201f1d; color: #ece9e2;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1rem .5rem; }
.brand { font-weight: 600; letter-spacing: .02em; }
.new-chat {
  margin: .5rem 1rem 1rem; padding: .55rem .9rem; border: 1px solid #47453f; border-radius: 10px;
  background: transparent; color: inherit; font: inherit; cursor: pointer; text-align: left;
}
.new-chat:hover { background: #2c2b28; }
.conv-list { flex: 1; overflow-y: auto; padding: 0 .5rem; }
.conv {
  display: block; width: 100%; text-align: left; padding: .5rem .6rem; margin-bottom: 2px;
  border: 0; border-radius: 8px; background: transparent; color: #d8d4cb; font: inherit; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv:hover { background: #2c2b28; }
.conv.active { background: #3a3835; color: #fff; }
.conv .badge {
  font-size: .7rem; padding: .05rem .4rem; border-radius: 6px; margin-right: .4rem;
  background: #3d5a80; color: #dbe7f3; vertical-align: 1px;
}
.conv .badge.web { background: #4a5d43; color: #e2eedd; }
.sidebar-foot { display: flex; align-items: center; justify-content: space-between; padding: .75rem 1rem; border-top: 1px solid #35332f; font-size: .85rem; color: #a5a196; }
.link-btn { border: 0; background: none; color: #a5a196; font: inherit; cursor: pointer; text-decoration: underline; }
.link-btn:hover { color: #fff; }

/* ── main column ── */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-head {
  display: flex; align-items: center; gap: .5rem; padding: .6rem 1rem;
  border-bottom: 1px solid #e5e2da; background: #f7f6f3;
}
.chat-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spacer { flex: 1; }
.icon-btn { border: 0; background: none; font: inherit; font-size: 1rem; cursor: pointer; color: inherit; padding: .3rem .45rem; border-radius: 8px; }
.icon-btn:hover { background: #eceae4; }
.sidebar .icon-btn:hover { background: #2c2b28; }
.ghost-btn {
  border: 1px solid #d7d3c9; border-radius: 8px; background: #fff; font: inherit; font-size: .85rem;
  padding: .3rem .7rem; cursor: pointer; color: #5d5a52;
}
.ghost-btn:hover { background: #eceae4; }
#open-sidebar { display: none; }

/* ── messages ── */
.messages { flex: 1; overflow-y: auto; padding: 1.5rem 1rem 1rem; }
.msg { max-width: 46rem; margin: 0 auto 1.1rem; }
.msg-user { display: flex; justify-content: flex-end; }
.msg-user .bubble {
  background: #e8e5dd; border-radius: 14px 14px 4px 14px; padding: .6rem .9rem; max-width: 85%;
  white-space: pre-wrap; overflow-wrap: break-word;
}
.msg-user .files { font-size: .8rem; color: #6d6a61; margin-top: .25rem; text-align: right; }
/* Origin mark (D-052): the message came through the OTHER channel. */
.msg-user .origin { font-size: .72rem; color: #8a8778; margin-bottom: .2rem; text-align: right; }
.msg-user .thumbs { text-align: right; margin-bottom: .3rem; }
.thumb {
  max-width: 220px; max-height: 220px; border-radius: 12px; display: inline-block;
  margin-left: .4rem; border: 1px solid #e0dcd2; object-fit: cover;
}
.chip-thumb { height: 44px; border-radius: 8px; margin-right: .4rem; vertical-align: middle; border: 1px solid #d7d3c9; }
.partial-note { font-size: .8rem; color: #8b877c; margin-top: -.3rem; margin-bottom: .5rem; }
.msg-assistant .content { overflow-wrap: break-word; }
.msg-assistant .content p { margin: 0 0 .7rem; }
.msg-assistant .content pre {
  background: #24231f; color: #e8e6df; padding: .8rem 1rem; border-radius: 10px; font-size: .88rem;
  white-space: pre-wrap; overflow-wrap: break-word; position: relative;
}
.copy-btn {
  position: absolute; top: .45rem; right: .45rem; border: 1px solid #4a4842; border-radius: 7px;
  background: #34322d; color: #cfccc4; font-size: .72rem; padding: .15rem .55rem; cursor: pointer;
}
.copy-btn:hover { background: #45433d; color: #fff; }
.msg-assistant .content code { background: #ecebe5; padding: .05rem .3rem; border-radius: 5px; font-size: .9em; }
.msg-assistant .content pre code { background: none; padding: 0; }
.msg-assistant .content ul, .msg-assistant .content ol { margin: 0 0 .7rem; padding-left: 1.4rem; }
.msg-assistant .content h1, .msg-assistant .content h2, .msg-assistant .content h3 { margin: 1rem 0 .5rem; font-size: 1.05rem; }
.msg-assistant .content a { color: #2f6b4f; }
.msg-system { text-align: center; }
.msg-system .divider { color: #8b877c; font-size: .8rem; }
.msg-error .card {
  background: #fdecea; border: 1px solid #f3c1bd; color: #8c2f28; border-radius: 10px;
  padding: .6rem .9rem; max-width: 46rem; margin: 0 auto;
}
.approval .card {
  background: #fff8e6; border: 1px solid #ecd9a0; border-radius: 10px; padding: .7rem .9rem;
}
.approval button { margin-right: .5rem; margin-top: .5rem; }
.cursor { display: inline-block; width: .55em; height: 1.05em; background: #8b877c; vertical-align: -0.15em; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.load-older { display: block; margin: 0 auto 1rem; }

/* ── composer ── */
.composer { padding: .5rem 1rem 1.1rem; }
.status-line {
  max-width: 46rem; margin: 0 auto .4rem; font-size: .85rem; color: #6d6a61;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.status-line::before { content: "✦ "; color: #b4762f; }
.chips { max-width: 46rem; margin: 0 auto .4rem; font-size: .85rem; color: #4a5d43; }
.input-row {
  display: flex; gap: .5rem; align-items: flex-end; max-width: 46rem; margin: 0 auto;
  background: #fff; border: 1px solid #d7d3c9; border-radius: 14px; padding: .45rem .55rem;
}
.input-row:focus-within { border-color: #b4762f; box-shadow: 0 0 0 3px rgba(180,118,47,.12); }
#input {
  flex: 1; border: 0; resize: none; font: inherit; outline: none; background: none;
  max-height: 12rem; padding: .25rem 0;
}
.send-btn, .stop-btn {
  border: 0; border-radius: 10px; width: 2.2rem; height: 2.2rem; font-size: 1.05rem; cursor: pointer; flex: none;
}
.send-btn { background: #b4762f; color: #fff; }
.send-btn:disabled { background: #d7d3c9; cursor: default; }
.stop-btn { background: #8c2f28; color: #fff; }

/* ── settings modal (D-053) ── */
.modal {
  position: fixed; inset: 0; background: rgba(28, 27, 23, .55); z-index: 20;
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.modal-card {
  background: #faf9f5; border-radius: 16px; width: 100%; max-width: 34rem;
  max-height: 88vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: .9rem 1.2rem; border-bottom: 1px solid #e0dcd2; font-weight: 600;
  position: sticky; top: 0; background: #faf9f5;
}
.modal-body { padding: .4rem 1.2rem 1.2rem; }
.set-section { margin-top: 1rem; }
.set-section h3 { font-size: .95rem; margin: 0 0 .5rem; }
.set-row { display: flex; align-items: center; gap: .6rem; padding: .25rem 0; flex-wrap: wrap; }
.set-name { min-width: 8rem; }
.muted { color: #8b877c; font-size: .85rem; }
.set-connect { border: 1px solid #e0dcd2; border-radius: 10px; padding: .7rem .9rem; margin: .5rem 0; }
.set-connect.ok { border-color: #b9d3ad; background: #f0f6ec; }
.set-connect.err { border-color: #f3c1bd; background: #fdecea; }
.set-connect ol { margin: .5rem 0; padding-left: 1.3rem; }
.big-code {
  font-size: 1.25rem; letter-spacing: .12em; background: #ecebe5;
  padding: .2rem .6rem; border-radius: 8px; user-select: all;
}
.code-row { display: flex; gap: .5rem; margin: .5rem 0; flex-wrap: wrap; }
.code-row input {
  flex: 1; min-width: 12rem; border: 1px solid #d7d3c9; border-radius: 8px;
  padding: .4rem .6rem; font: inherit; outline: none;
}
.code-row input:focus { border-color: #b4762f; }
.ghost-btn.current { border-color: #b4762f; }

/* ── dictation (D-055) ── */
#mic.recording { background: #fdecea; border-radius: 10px; animation: mic-pulse 1.2s ease-in-out infinite; }
@keyframes mic-pulse { 50% { box-shadow: 0 0 0 6px rgba(140, 47, 40, .18); } }

/* ── responsive ── */
@media (max-width: 768px) {
  .sidebar { position: fixed; inset: 0 20% 0 0; z-index: 10; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  #open-sidebar { display: inline-block; }
  #collapse { display: inline-block; }
}
@media (min-width: 769px) {
  #collapse { display: none; }
}
