/* =====================================================================
   Hooshi V5.2 — Premium Minimal UI
   Quiet surfaces, full-width chat, drawer navigation and responsive polish.
   ===================================================================== */

:root {
  --premium-bg: #f6f5f2;
  --premium-surface: rgba(255, 255, 255, .86);
  --premium-surface-solid: #fdfcfb;
  --premium-line: rgba(28, 25, 40, .075);
  --premium-line-strong: rgba(28, 25, 40, .12);
  --premium-ink: #1c1925;
  --premium-muted: #746f7f;
  --premium-accent: #6f5bd8;
  --premium-accent-soft: rgba(111, 91, 216, .10);
  --premium-shadow: 0 24px 70px -54px rgba(30, 22, 58, .55);
  --premium-shadow-raised: 0 24px 70px -42px rgba(30, 22, 58, .28);
  --premium-radius: 22px;
  --premium-radius-sm: 15px;
  --premium-content: 1380px;
  --chat-max: 940px;
}

[data-theme="dark"] {
  --premium-bg: #101013;
  --premium-surface: rgba(27, 26, 31, .88);
  --premium-surface-solid: #1a191e;
  --premium-line: rgba(255, 255, 255, .07);
  --premium-line-strong: rgba(255, 255, 255, .12);
  --premium-ink: #f3f1f7;
  --premium-muted: #9e99aa;
  --premium-accent: #a493ff;
  --premium-accent-soft: rgba(164, 147, 255, .12);
  --premium-shadow: 0 24px 70px -52px rgba(0, 0, 0, .95);
  --premium-shadow-raised: 0 28px 75px -46px rgba(0, 0, 0, .86);
}

/* ---------- Global calm ---------- */
body {
  background: var(--premium-bg);
  color: var(--premium-ink);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -3;
  pointer-events: none;
  background:
    radial-gradient(700px 460px at 82% -12%, rgba(111, 91, 216, .075), transparent 70%),
    radial-gradient(620px 420px at 6% 104%, rgba(193, 151, 111, .055), transparent 72%);
}

.aurora { opacity: .18; }
.aurora::before { animation-duration: 48s; filter: blur(48px); }
.aurora .orb { opacity: .18; filter: blur(90px); animation-duration: 34s; }

.glass,
.panel,
.stat-card,
.tool-card,
.feature,
.plan,
.guide-sec,
.admin-hero,
.result-card,
.tool-form-card {
  background: var(--premium-surface);
  border-color: var(--premium-line);
  box-shadow: var(--premium-shadow);
  -webkit-backdrop-filter: blur(18px) saturate(115%);
  backdrop-filter: blur(18px) saturate(115%);
}

.panel,
.stat-card,
.tool-card,
.feature,
.plan,
.guide-sec,
.admin-hero,
.result-card,
.tool-form-card { border-radius: var(--premium-radius); }

.btn {
  --bg: var(--premium-accent);
  box-shadow: 0 14px 34px -22px rgba(75, 56, 160, .72);
  font-weight: 700;
  letter-spacing: -.01em;
}
.btn:hover { filter: none; transform: translateY(-1px); box-shadow: 0 18px 38px -22px rgba(75, 56, 160, .72); }
.btn.ghost { background: var(--premium-surface); border-color: var(--premium-line); }
.icon-btn {
  background: rgba(255, 255, 255, .58);
  border-color: var(--premium-line);
  box-shadow: none;
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}
[data-theme="dark"] .icon-btn { background: rgba(255, 255, 255, .045); }
.icon-btn:hover { transform: none; background: var(--premium-surface-solid); border-color: var(--premium-line-strong); }

/* ---------- Public pages ---------- */
.site-header { padding: 12px 0; }
.site-header .bar {
  background: color-mix(in srgb, var(--premium-surface-solid) 82%, transparent);
  border: 1px solid var(--premium-line);
  border-radius: 20px;
  box-shadow: 0 18px 54px -46px rgba(31, 25, 52, .50);
  -webkit-backdrop-filter: blur(18px) saturate(115%);
  backdrop-filter: blur(18px) saturate(115%);
}
.brand-logo .mark,
.icon-orb,
.chat-brand-mark,
.welcome-mark {
  background: var(--premium-accent) !important;
  box-shadow: 0 14px 30px -22px rgba(78, 59, 168, .85) !important;
}
.hero .container::before { opacity: .34; filter: blur(30px); }
.tool-card:hover,
.feature:hover,
.price-card:hover { transform: translateY(-2px); box-shadow: var(--premium-shadow-raised); }

/* ---------- App shell: no blank strip behind sidebar ---------- */
.app-shell {
  width: 100%;
  max-width: none !important;
  margin: 0 !important;
  grid-template-columns: 248px minmax(0, 1fr);
  background: transparent;
}
.app-main { width: 100%; min-width: 0; }
.app-content { width: 100%; }
.page-app:not(.page-chat) .app-content > :first-child {
  width: min(100%, var(--premium-content));
  margin-inline: auto;
}

.app-sidebar {
  position: sticky;
  inset-block-start: 0;
  height: 100dvh;
  padding: 18px 14px 16px;
  background: color-mix(in srgb, var(--premium-surface-solid) 90%, transparent);
  border-inline-start: 0;
  border-inline-end: 1px solid var(--premium-line);
  box-shadow: none;
  -webkit-backdrop-filter: blur(24px) saturate(112%);
  backdrop-filter: blur(24px) saturate(112%);
}
.app-sidebar .side-brand {
  min-height: 50px;
  padding: 7px 10px 15px;
  font-size: 17px;
  letter-spacing: -.02em;
}
.side-nav { gap: 4px; }
.side-nav a {
  min-height: 43px;
  padding: 9px 12px;
  border-radius: 13px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--premium-muted);
}
.side-nav a:hover { background: rgba(111, 91, 216, .055); color: var(--premium-ink); }
.side-nav a.active {
  background: var(--premium-accent-soft);
  color: var(--premium-accent);
  box-shadow: none;
}
.side-nav a.active::before { display: none; }
.side-nav a svg { opacity: .82; }
.side-foot { padding-top: 12px; }
.limit-card,
.user-pill {
  background: rgba(111, 91, 216, .045);
  border: 1px solid var(--premium-line);
  box-shadow: none;
}
.limit-card .lc-bar { height: 5px; background: rgba(111, 91, 216, .10); }
.limit-card .lc-bar i { background: var(--premium-accent); }
.user-pill .av { background: var(--premium-accent); }

.sidebar-close {
  display: none;
  position: absolute;
  inset-inline-end: 14px;
  inset-block-start: 14px;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--premium-line);
  border-radius: 50%;
  background: var(--premium-surface);
  color: var(--premium-ink);
  z-index: 4;
}

.app-topbar {
  min-height: 64px;
  padding: 11px clamp(16px, 2.6vw, 34px);
  background: color-mix(in srgb, var(--premium-bg) 88%, transparent);
  border: 0;
  border-bottom: 1px solid var(--premium-line);
  border-radius: 0;
  box-shadow: none;
  -webkit-backdrop-filter: blur(18px) saturate(112%);
  backdrop-filter: blur(18px) saturate(112%);
}
.app-topbar h1 { font-size: 17px; font-weight: 650; letter-spacing: -.015em; }

/* ---------- Focused chat: drawer only, full canvas ---------- */
.page-chat {
  --topbar-h: 62px;
  background: var(--premium-bg);
}
.page-chat .aurora { display: none; }
.page-chat .app-shell {
  display: block !important;
  width: 100%;
  height: var(--app-viewport-height, 100dvh);
}
.page-chat .app-main {
  width: 100%;
  height: var(--app-viewport-height, 100dvh);
}
.page-chat .app-sidebar {
  display: flex;
  position: fixed !important;
  inset: 0 0 0 auto;
  width: min(316px, 88vw) !important;
  height: var(--app-viewport-height, 100dvh);
  z-index: 220;
  transform: translateX(104%) !important;
  transition: transform .32s cubic-bezier(.22, 1, .36, 1);
  border-inline-start: 1px solid var(--premium-line);
  box-shadow: -34px 0 90px -58px rgba(25, 20, 47, .78);
  padding-top: 72px;
}
.page-chat .app-sidebar.open { transform: translateX(0) !important; }
.page-chat .sidebar-close { display: grid; }
.page-chat .app-topbar .menu-toggle { display: inline-grid !important; }
.page-chat .app-topbar {
  position: relative;
  min-height: var(--topbar-h);
  flex: 0 0 var(--topbar-h);
  padding: 9px clamp(12px, 2.5vw, 28px);
  background: color-mix(in srgb, var(--premium-bg) 88%, transparent);
  border-bottom-color: rgba(28, 25, 40, .055);
  z-index: 80;
}
[data-theme="dark"] .page-chat .app-topbar { border-bottom-color: rgba(255,255,255,.055); }
.page-chat .app-topbar .icon-btn { width: 40px; height: 40px; }
.chat-topbar-brand {
  position: absolute;
  inset-inline-start: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  letter-spacing: -.02em;
}
.chat-brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  color: #fff;
  display: grid;
  place-items: center;
}
.page-chat .app-content { width: 100%; padding: 0; }
.page-chat .chat-shell {
  position: relative;
  background:
    radial-gradient(640px 360px at 50% 4%, rgba(111, 91, 216, .045), transparent 72%),
    var(--premium-bg);
}
.chat-ambient { display: none !important; }

.sidebar-backdrop {
  background: rgba(19, 17, 25, .22);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}
.sidebar-backdrop.show { opacity: 1; }

/* ---------- Chat welcome ---------- */
.chat-stream {
  padding: clamp(24px, 4vw, 54px) clamp(16px, 4vw, 44px) 28px;
  scroll-padding-block: 28px 48px;
}
.chat-inner,
.composer-inner { width: min(var(--chat-max), 100%); }
.chat-inner { gap: 26px; }
.chat-welcome {
  min-height: min(520px, 62vh);
  display: grid;
  align-content: center;
  justify-items: center;
  padding: 34px 18px 42px;
  margin: 0;
}
.welcome-mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  color: #fff;
  margin-bottom: 18px;
}
.chat-welcome h2 {
  max-width: 620px;
  font-size: clamp(23px, 3vw, 34px);
  line-height: 1.55;
  font-weight: 680;
  letter-spacing: -.035em;
  margin: 0;
  text-wrap: balance;
}
.chat-welcome p {
  max-width: 580px;
  margin: 10px auto 0;
  color: var(--premium-muted);
  font-size: 14px;
  line-height: 2;
  text-wrap: pretty;
}
.welcome-live {
  margin-top: 15px;
  padding: 5px 10px;
  border: 0;
  background: transparent;
  color: var(--premium-muted);
  font-size: 11px;
}
.welcome-live i { width: 6px; height: 6px; box-shadow: 0 0 0 4px rgba(16,185,129,.08); }
.suggestions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  width: min(700px, 100%);
  margin: 24px auto 0;
}
.suggestion {
  min-height: 40px;
  width: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 13px;
  border: 1px solid var(--premium-line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--premium-surface-solid) 72%, transparent);
  color: var(--premium-muted);
  font-size: 12px;
  box-shadow: none;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}
.suggestion:hover {
  transform: none;
  color: var(--premium-ink);
  border-color: rgba(111, 91, 216, .20);
  background: var(--premium-accent-soft);
  box-shadow: none;
}

/* ---------- Messages: less card-like, more editorial ---------- */
.msg,
.chat-typing { gap: 10px; }
.msg .avatar,
.chat-typing .avatar {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  margin-top: 2px;
  font-size: 11px;
  box-shadow: none;
}
.msg.user .avatar { display: none; }
.msg.user { justify-content: flex-start; }
.msg .bubble,
.chat-typing .bubble { max-width: min(100%, 800px); }
.msg.bot .bubble {
  width: min(100%, 800px);
  padding: 2px 4px 4px;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
.msg.user .bubble {
  max-width: min(78%, 650px);
  padding: 11px 15px;
  border: 1px solid rgba(111, 91, 216, .10);
  border-radius: 18px 18px 6px 18px;
  background: var(--premium-accent-soft);
  color: var(--premium-ink);
  box-shadow: none;
}
.msg-body {
  color: var(--premium-ink);
  line-height: 2;
  font-size: 14.5px;
}
.msg-body .md-h {
  margin: 1.25em 0 .45em;
  font-size: 1.03em;
  font-weight: 720;
}
.msg-body .md-p { margin: .58em 0; }
.msg-body .md-ul,
.msg-body .md-ol { padding-inline-start: 20px; }
.msg-actions { opacity: .42; transition: opacity .2s ease; }
.msg:hover .msg-actions,
.msg:focus-within .msg-actions { opacity: 1; }
.chat-typing .bubble {
  padding: 9px 13px;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.hooshi-card,
.answer-highlight,
.hooshi-metric {
  border-radius: var(--premium-radius-sm);
  border-color: var(--premium-line);
  box-shadow: none;
}
.hooshi-card { padding: 12px 14px; }
.hooshi-card-info,
.answer-highlight-info { background: rgba(111, 91, 216, .06); }
.hooshi-metric { background: rgba(111, 91, 216, .045); }
.evidence-bar {
  margin-top: 14px;
  padding-top: 9px;
  border-top-color: var(--premium-line);
  color: var(--premium-muted);
}
.evidence-source { background: rgba(111, 91, 216, .055); }

/* ---------- Composer: one quiet premium object ---------- */
.chat-composer {
  padding: 8px clamp(13px, 4vw, 44px) max(13px, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, transparent, var(--premium-bg) 26%, var(--premium-bg));
  border: 0;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
.chat-composer::before { display: none; }
.composer-inner { position: relative; }
.chat-context-bar {
  width: max-content;
  max-width: 100%;
  min-height: 32px;
  margin: 0 auto 7px;
  padding: 3px 5px 3px 9px;
  gap: 8px;
  border: 0;
  border-radius: 999px;
  background: rgba(111, 91, 216, .055);
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
.site-switch { gap: 7px; }
.switch-ui { width: 34px; height: 20px; padding: 3px; background: rgba(31, 27, 44, .16); }
.switch-ui i { width: 14px; height: 14px; box-shadow: 0 2px 5px rgba(0,0,0,.15); }
.site-switch input:checked + .switch-ui { background: var(--premium-accent); }
.site-switch input:checked + .switch-ui i { transform: translateX(-14px); }
.site-switch b { font-size: 11px; font-weight: 650; }
.context-picker {
  width: auto;
  max-width: 190px;
  min-height: 26px;
  padding: 3px 9px;
  border: 0;
  border-radius: 999px;
  background: var(--premium-surface-solid);
  font-size: 10.5px;
  box-shadow: none;
}
.privacy-note { margin: 0; font-size: 9.5px; color: var(--premium-muted); white-space: nowrap; }
.composer-box {
  min-height: 64px;
  padding: 9px 10px 9px 18px !important;
  border: 1px solid var(--premium-line-strong) !important;
  border-radius: 22px !important;
  background: color-mix(in srgb, var(--premium-surface-solid) 93%, transparent) !important;
  box-shadow: var(--premium-shadow-raised) !important;
  -webkit-backdrop-filter: blur(18px) saturate(108%);
  backdrop-filter: blur(18px) saturate(108%);
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
.composer-box::before { display: none !important; }
.composer-box:focus-within {
  border-color: rgba(111, 91, 216, .36) !important;
  background: var(--premium-surface-solid) !important;
  box-shadow: 0 24px 68px -40px rgba(44, 34, 86, .42), 0 0 0 3px rgba(111, 91, 216, .07) !important;
}
.composer-box textarea {
  min-height: 38px;
  padding: 7px 0 5px;
  color: var(--premium-ink);
  font-size: 15px;
  line-height: 1.8;
}
.composer-box textarea::placeholder { color: color-mix(in srgb, var(--premium-muted) 72%, transparent); }
.composer-send {
  width: 45px;
  height: 45px;
  border-radius: 15px;
  background: var(--premium-accent);
  box-shadow: 0 13px 28px -19px rgba(75, 55, 166, .92);
  transition: opacity .2s ease, transform .2s ease, background .2s ease;
}
.composer-send:not(:disabled):hover { transform: translateY(-1px); }
.composer-send:disabled { opacity: .32; }
.page-chat .composer-foot { display: none !important; }

.customer-entry-toast {
  position: absolute;
  inset-block-start: 12px;
  inset-inline-start: 50%;
  z-index: 45;
  width: min(460px, calc(100% - 28px));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 13px;
  border: 1px solid rgba(16, 185, 129, .14);
  border-radius: 15px;
  background: color-mix(in srgb, var(--premium-surface-solid) 92%, transparent);
  box-shadow: var(--premium-shadow);
  color: var(--premium-ink);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}
.customer-entry-toast > span { color: #0b9d70; flex: 0 0 auto; }
.customer-entry-toast b { font-size: 12px; }
.customer-entry-toast small { display: block; margin-top: 1px; color: var(--premium-muted); font-size: 10px; }

/* ---------- Admin and dashboards ---------- */
.adm-table-wrap { border: 1px solid var(--premium-line); background: var(--premium-surface); }
.adm-table th { color: var(--premium-muted); font-weight: 650; }
.adm-table tr:hover td { background: rgba(111, 91, 216, .025); }
.input,
.select,
.textarea,
input,
select,
textarea { border-color: var(--premium-line-strong); }
.input:focus,
.select:focus,
.textarea:focus,
input:focus,
select:focus,
textarea:focus { border-color: rgba(111, 91, 216, .38); box-shadow: 0 0 0 3px rgba(111, 91, 216, .07); }

/* ---------- Drawer mode for tablet/mobile ---------- */
@media (max-width: 1024px) {
  .app-shell { display: block; }
  .app-sidebar {
    position: fixed;
    inset: 0 0 0 auto;
    width: min(316px, 88vw) !important;
    height: var(--app-viewport-height, 100dvh);
    z-index: 220;
    transform: translateX(104%);
    transition: transform .32s cubic-bezier(.22, 1, .36, 1);
    padding-top: 70px;
    box-shadow: -34px 0 90px -58px rgba(25, 20, 47, .78);
  }
  .app-sidebar.open { transform: translateX(0); }
  .sidebar-close { display: grid; }
  .app-topbar .menu-toggle { display: inline-grid; }
}

@media (max-width: 720px) {
  :root { --premium-radius: 19px; }
  .aurora { opacity: .10; }
  .app-topbar { min-height: 58px; padding: 8px 10px; }
  .page-chat { --topbar-h: 56px; }
  .page-chat .app-topbar { padding: 7px 9px; }
  .page-chat .app-topbar .icon-btn { width: 38px; height: 38px; }
  .chat-topbar-brand b { font-size: 13px; }
  .chat-brand-mark { width: 28px; height: 28px; border-radius: 9px; }

  .chat-stream { padding: 17px 11px 20px; }
  .chat-welcome {
    min-height: min(470px, 60vh);
    padding: 22px 5px 32px;
  }
  .welcome-mark { width: 48px; height: 48px; border-radius: 16px; margin-bottom: 14px; }
  .chat-welcome h2 { font-size: clamp(21px, 6.6vw, 28px); line-height: 1.55; }
  .chat-welcome p { font-size: 13px; line-height: 1.9; }
  .suggestions { gap: 7px; margin-top: 19px; }
  .suggestion {
    width: 100%;
    min-height: 42px;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(255,255,255,.46);
  }
  [data-theme="dark"] .suggestion { background: rgba(255,255,255,.035); }

  .msg .avatar,
  .chat-typing .avatar { width: 27px; height: 27px; border-radius: 9px; }
  .msg.bot .bubble { padding-inline: 1px; }
  .msg.user .bubble { max-width: 88%; padding: 10px 13px; }
  .msg-body { font-size: 14px; line-height: 1.95; }
  .msg-actions { opacity: .72; }

  .chat-composer { padding: 6px 8px max(8px, env(safe-area-inset-bottom)); }
  .chat-context-bar {
    width: 100%;
    min-height: 30px;
    justify-content: center;
    padding-inline: 6px;
    overflow: hidden;
  }
  .privacy-note { display: none; }
  .context-picker { min-width: 0; max-width: 43vw; }
  .composer-box {
    min-height: 57px;
    grid-template-columns: minmax(0, 1fr) 42px;
    padding: 7px 7px 7px 13px !important;
    border-radius: 19px !important;
  }
  .composer-box textarea { font-size: 16px; max-height: min(132px, 23dvh); }
  .composer-send { width: 42px; height: 42px; border-radius: 13px; }
  .customer-entry-toast { inset-block-start: 8px; }
}

@media (max-width: 420px) {
  .page-chat .app-sidebar { width: min(300px, 91vw) !important; }
  .chat-welcome { min-height: min(430px, 58vh); }
  .suggestions .suggestion:nth-child(n+4) { display: none; }
  .chat-context-bar { justify-content: space-between; }
  .context-picker { max-width: 48vw; }
}

@media (max-height: 650px) and (orientation: landscape) {
  .chat-welcome { min-height: 300px; padding-block: 20px; }
  .welcome-mark { width: 42px; height: 42px; margin-bottom: 10px; }
  .chat-welcome p { display: none; }
  .suggestions { margin-top: 12px; }
  .chat-context-bar { margin-bottom: 4px; }
  .composer-box { min-height: 52px; }
}

@media (prefers-reduced-motion: reduce) {
  .app-sidebar,
  .suggestion,
  .composer-send,
  .msg,
  .answer-arrived { transition: none !important; animation: none !important; }
}

/* V5.3 — recovery state: quiet, readable and consistent with the minimal chat */
.chat-recovery{display:grid;gap:12px;max-width:620px}
.chat-recovery p{margin:0;line-height:1.9;color:var(--ink-soft,var(--ink))}
.chat-recovery .row-flex{display:flex;flex-wrap:wrap}
.chat-recovery [data-retry-chat]{min-height:38px;border-radius:12px}
