/* Yoom app — AI worker workspace (wallet auth via Phantom). Vanilla JS, no deps. */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #F9FAFB;
  --border: #E5E7EB;
  --text: #111827;
  --text-2: #4B5563;
  --text-3: #6B7280;
  --active: #2563EB;
  --accent: #3B82F6;
  --btn: #111827;
  --radius: 8px;
}

html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

.hidden { display: none !important; }

/* ---------- AUTH SCREEN ---------- */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(1200px 600px at 50% -10%, #EFF6FF 0%, var(--bg) 60%);
  padding: 24px;
}
.auth-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 8px 30px rgba(17,24,39,.06);
  padding: 44px 40px 36px;
  width: 100%;
  max-width: 400px;
  text-align: center;
}
.auth-logo { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 18px; }
.auth-logo-img { width: 30px; height: 30px; }
.auth-brand { font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.auth-title { font-size: 17px; font-weight: 700; margin-bottom: 6px; }
.auth-sub { color: var(--text-3); margin-bottom: 26px; }
.wallet-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  background: var(--btn); color: #fff; border: none; border-radius: 10px;
  font-size: 15px; font-weight: 600; padding: 12px 22px; cursor: pointer; width: 100%;
  transition: opacity .15s;
}
.wallet-btn:hover { opacity: .9; }
.wallet-btn:disabled { opacity: .6; cursor: wait; }
.auth-error { color: #DC2626; font-size: 13px; margin-top: 14px; min-height: 18px; }
.auth-install { color: var(--text-3); font-size: 13px; margin-top: 14px; }
.auth-install a { color: var(--active); }

/* ---------- APP SHELL — WORKSPACE ---------- */
.app-shell { height: 100vh; overflow: hidden; }
.app-layout { display: flex; height: 100%; }

/* SIDEBAR */
.sidebar {
  width: 272px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-right: 1px solid var(--border);
  min-height: 0;
}
.side-brand {
  display: flex; align-items: center; gap: 9px;
  padding: 16px 18px 10px;
}
.brand-icon { width: 26px; height: 26px; }
.brand-name { font-size: 17px; font-weight: 700; letter-spacing: -.02em; flex: 1; }
.side-close { display: none; background: none; border: none; font-size: 15px; color: var(--text-3); cursor: pointer; padding: 4px; }

.new-chat-btn {
  margin: 4px 14px 10px;
  padding: 10px 12px;
  background: var(--btn); color: #fff;
  border: none; border-radius: 10px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  transition: opacity .15s;
}
.new-chat-btn:hover { opacity: .9; }

.conv-list { flex: 1; overflow-y: auto; padding: 0 10px 8px; min-height: 0; }
.conv-empty { color: var(--text-3); font-size: 12px; padding: 18px 8px; text-align: center; }
.conv-item {
  display: flex; align-items: center; gap: 4px;
  border-radius: 8px; margin-bottom: 2px;
}
.conv-item:hover { background: #F3F4F6; }
.conv-item.active { background: #EFF6FF; }
.conv-open {
  flex: 1; min-width: 0;
  background: none; border: none; cursor: pointer;
  text-align: left; font-size: 13px; color: var(--text-2);
  padding: 8px 10px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.conv-item.active .conv-open { color: var(--active); font-weight: 600; }
.conv-del {
  background: none; border: none; cursor: pointer;
  font-size: 12px; color: var(--text-3); padding: 6px; border-radius: 6px;
  opacity: 0; flex-shrink: 0;
}
.conv-item:hover .conv-del { opacity: 1; }
.conv-del:hover { background: #FEE2E2; color: #DC2626; }

.side-bottom { border-top: 1px solid var(--border); padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 10px; }
.side-row { display: flex; flex-direction: column; gap: 5px; }
.side-label { font-size: 11px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .03em; }
.side-inline { display: flex; gap: 6px; align-items: center; }
.side-select {
  flex: 1; min-width: 0;
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 9px; font-size: 13px; color: var(--text); background: #fff;
  outline: none; cursor: pointer; font-family: inherit;
}
.side-select:focus { border-color: var(--accent); }
.icon-btn {
  background: #F3F4F6; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; color: var(--text-2); cursor: pointer;
  width: 34px; height: 34px; flex-shrink: 0;
}
.icon-btn:hover { background: #E5E7EB; }

.side-user { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-3); min-width: 0; padding-top: 2px; }
.wallet-dot { width: 8px; height: 8px; border-radius: 50%; background: #22C55E; flex-shrink: 0; }
.wallet-addr {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  flex: 1; min-width: 0;
}
.logout-btn {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  padding: 4px 10px; font-size: 11px; color: var(--text-2); cursor: pointer;
  flex-shrink: 0;
}
.logout-btn:hover { background: #F3F4F6; }

.side-scrim { display: none; }

/* MAIN */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  background: #fff;
  flex-shrink: 0;
}
.side-toggle {
  display: none; background: none; border: 1px solid var(--border); border-radius: 8px;
  font-size: 15px; color: var(--text-2); cursor: pointer; padding: 5px 9px;
}
.conv-title {
  flex: 1; min-width: 0;
  font-size: 15px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.top-right { display: flex; align-items: center; gap: 9px; }
.model-chip {
  font-size: 11px; color: var(--text-3); padding: 3px 9px;
  background: #F3F4F6; border-radius: 999px; white-space: nowrap;
}

.chat-scroll { flex: 1; overflow-y: auto; min-height: 0; }
.chat-body {
  max-width: 760px; margin: 0 auto;
  padding: 28px 20px 16px;
  display: flex; flex-direction: column; gap: 14px;
}
.msg {
  max-width: 88%; padding: 12px 15px; border-radius: 14px;
  font-size: 14px; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word;
}
.msg b { display: block; font-size: 11px; margin-bottom: 4px; opacity: .7; letter-spacing: .02em; text-transform: uppercase; }
.msg-ai { background: #fff; border: 1px solid var(--border); align-self: flex-start; border-bottom-left-radius: 5px; }
.msg-user { background: var(--active); color: #fff; align-self: flex-end; border-bottom-right-radius: 5px; }
.msg-user b { color: #DBEAFE; }
.chat-typing { color: var(--text-3); font-style: italic; }

.chat-composer {
  flex-shrink: 0;
  background: #fff;
  border-top: 1px solid var(--border);
  padding: 14px 20px 12px;
}
.chat-form {
  max-width: 760px; margin: 0 auto;
  display: flex; gap: 10px;
}
.chat-input {
  flex: 1;
  border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; font-size: 14px; outline: none; font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.chat-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,.12); }
.chat-send {
  background: var(--btn); color: #fff; border: none; border-radius: 10px;
  padding: 12px 22px; font-size: 14px; font-weight: 600; cursor: pointer;
  flex-shrink: 0;
}
.chat-send:hover { opacity: .9; }
.chat-send:disabled { opacity: .6; cursor: wait; }
.chat-foot {
  max-width: 760px; margin: 8px auto 0;
  color: #9CA3AF; font-size: 11px; text-align: center;
}

/* ---------- WORKER MODAL ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(17,24,39,.45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal {
  background: #fff; border-radius: 14px;
  width: 100%; max-width: 460px;
  padding: 24px;
  box-shadow: 0 20px 50px rgba(17,24,39,.18);
}
.modal h3 { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.modal-sub { color: var(--text-3); font-size: 12px; margin-bottom: 16px; }
.modal-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin: 12px 0 5px; }
.modal-input, .modal-textarea {
  width: 100%;
  border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; font-size: 13px; outline: none; font-family: inherit;
}
.modal-input:focus, .modal-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,.12); }
.modal-textarea { min-height: 130px; resize: vertical; }
.modal-actions { display: flex; align-items: center; gap: 8px; margin-top: 18px; }
.spacer { flex: 1; }
.btn-primary {
  background: var(--btn); color: #fff; border: none; border-radius: 8px;
  padding: 9px 16px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.btn-primary:hover { opacity: .9; }
.btn-primary:disabled { opacity: .6; cursor: wait; }
.btn-ghost {
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 14px; font-size: 13px; color: var(--text-2); cursor: pointer;
}
.btn-ghost:hover { background: #F3F4F6; }
.btn-danger {
  background: #fff; border: 1px solid #FECACA; border-radius: 8px;
  padding: 9px 14px; font-size: 13px; color: #DC2626; cursor: pointer;
}
.btn-danger:hover { background: #FEF2F2; }

/* ---------- TOAST ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--btn); color: #fff; padding: 10px 18px; border-radius: 10px;
  font-size: 13px; z-index: 300; box-shadow: 0 6px 24px rgba(17,24,39,.2);
  max-width: 90vw;
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 720px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 150;
    transform: translateX(-100%);
    transition: transform .18s ease;
    width: 280px;
    box-shadow: 0 0 40px rgba(17,24,39,.15);
  }
  .sidebar.open { transform: translateX(0); }
  .side-close { display: block; }
  .side-scrim.open {
    display: block; position: fixed; inset: 0; z-index: 140;
    background: rgba(17,24,39,.35);
  }
  .side-toggle { display: block; }
  .topbar { padding: 12px 14px; }
  .chat-body { padding: 20px 12px 10px; }
  .chat-composer { padding: 10px 12px 8px; }
  .msg { max-width: 94%; }
}
