/* Hina web chat — light, warm, mint + purple, very rounded, mobile-first */

:root {
  --bg: #F7F7F5;
  --card: #FFFFFF;
  --mint: #3DDC84;
  --mint-deep: #2BC873;
  --mint-soft: #E8FBF0;
  --purple: #8B5CF6;
  --purple-soft: #F1EDFE;
  --text: #1C1C1E;
  --text-muted: #7A7A80;
  --border: #EDEDEA;
  --danger: #E5484D;
  --danger-soft: #FDECEC;
  --shadow: 0 8px 30px rgba(28, 28, 30, 0.08);
  --shadow-sm: 0 2px 10px rgba(28, 28, 30, 0.06);
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-pill: 999px;
  --max-width: 760px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: "Outfit", "Hind Siliguri", -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

.hidden { display: none !important; }

.screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: var(--max-width);
  margin: 0 auto;
}

/* ---------- Login ---------- */

#login-screen {
  justify-content: center;
  align-items: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border-radius: 32px;
  box-shadow: var(--shadow);
  padding: 40px 28px 32px;
  text-align: center;
}

.login-avatar {
  width: 76px;
  height: 76px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--mint) 0%, var(--purple) 100%);
  color: #fff;
  font-size: 36px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 24px rgba(61, 220, 132, 0.35);
}

.login-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.login-sub {
  color: var(--text-muted);
  font-size: 15px;
  margin-top: 4px;
}

.login-hint {
  margin: 24px 0 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--purple);
}

/* ---------- Forms / buttons ---------- */

.field { text-align: left; margin-bottom: 14px; }

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0 0 6px 6px;
}

input[type="password"],
input[type="text"],
input[type="search"] {
  width: 100%;
  font-family: inherit;
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
  border: 2px solid transparent;
  border-radius: var(--radius-pill);
  padding: 13px 20px;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease;
}

input:focus {
  border-color: var(--mint);
  background: var(--card);
}

.btn-primary {
  width: 100%;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--mint) 0%, var(--mint-deep) 100%);
  border: none;
  border-radius: var(--radius-pill);
  padding: 14px 24px;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(61, 220, 132, 0.35);
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}

.btn-primary:active { transform: scale(0.97); }
.btn-primary:disabled { opacity: 0.6; cursor: default; transform: none; }

.btn-ghost {
  width: 100%;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: var(--radius-pill);
  padding: 12px;
  cursor: pointer;
  margin-top: 6px;
}

.btn-danger {
  width: 100%;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  color: var(--danger);
  background: var(--danger-soft);
  border: none;
  border-radius: var(--radius-pill);
  padding: 14px 24px;
  cursor: pointer;
  margin-top: 24px;
  transition: transform 0.12s ease;
}

.btn-danger:active { transform: scale(0.97); }

.error-text {
  color: var(--danger);
  font-size: 14px;
  font-weight: 600;
  background: var(--danger-soft);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin-bottom: 12px;
}

.success-text {
  color: var(--mint-deep);
  font-size: 14px;
  font-weight: 600;
  background: var(--mint-soft);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin-bottom: 12px;
}

/* ---------- App header ---------- */

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(247, 247, 245, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-left { display: flex; align-items: center; gap: 12px; }

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--mint) 0%, var(--purple) 100%);
  color: #fff;
  font-size: 20px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.header-title { display: flex; flex-direction: column; }

.header-name { font-size: 18px; font-weight: 800; line-height: 1.2; }

.header-status {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 0 3px var(--mint-soft);
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--card);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s ease, background 0.12s ease;
  flex-shrink: 0;
}

.icon-btn:active { transform: scale(0.92); }

/* ---------- Main / views ---------- */

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 16px 12px;
  -webkit-overflow-scrolling: touch;
}

.view-heading { margin: 4px 4px 16px; }
.view-heading h2 { font-size: 22px; font-weight: 800; }
.view-heading p { font-size: 14px; color: var(--text-muted); margin-top: 2px; }

/* ---------- Chat ---------- */

.same-hina-note {
  align-self: center;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--purple-soft);
  color: var(--purple);
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-pill);
  padding: 8px 16px;
  margin-bottom: 16px;
  text-align: center;
}

.note-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--purple);
  flex-shrink: 0;
}

.chat-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg {
  max-width: 85%;
  padding: 12px 16px;
  font-size: 16px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  animation: msg-in 0.18s ease;
}

@keyframes msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--mint) 0%, #4ADE80 100%);
  color: #fff;
  border-radius: 22px 22px 6px 22px;
  box-shadow: 0 4px 14px rgba(61, 220, 132, 0.3);
}

.msg-assistant {
  align-self: flex-start;
  background: var(--card);
  border-radius: 22px 22px 22px 6px;
  box-shadow: var(--shadow-sm);
}

.msg-error {
  align-self: center;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-pill);
  padding: 9px 16px;
  max-width: 92%;
  text-align: center;
}

.typing { display: inline-flex; gap: 4px; align-items: center; }
.typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  opacity: 0.5;
  animation: typing-bounce 1.2s infinite;
}
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px 16px;
}

.empty-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--mint) 0%, var(--purple) 100%);
  color: #fff;
  font-size: 34px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  box-shadow: 0 10px 24px rgba(139, 92, 246, 0.25);
}

.empty-title { font-size: 22px; font-weight: 800; }
.empty-sub { color: var(--text-muted); font-size: 15px; margin-top: 4px; }

/* ---------- Composer ---------- */

.composer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid var(--border);
}

.composer input {
  flex: 1;
  background: var(--card);
  box-shadow: var(--shadow-sm);
}

.send-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--mint) 0%, var(--mint-deep) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(61, 220, 132, 0.4);
  transition: transform 0.12s ease, opacity 0.12s ease;
  flex-shrink: 0;
}

.send-btn:active { transform: scale(0.9); }
.send-btn:disabled { opacity: 0.5; cursor: default; transform: none; }

.voice-btn.listening {
  background: var(--danger-soft);
  color: var(--danger);
  animation: pulse-ring 1.4s infinite;
}

@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(229, 72, 77, 0.35); }
  70% { box-shadow: 0 0 0 10px rgba(229, 72, 77, 0); }
  100% { box-shadow: 0 0 0 0 rgba(229, 72, 77, 0); }
}

/* ---------- Tab bar ---------- */

.tabbar {
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding: 6px 8px calc(8px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 20px rgba(28, 28, 30, 0.05);
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  padding: 8px 0 6px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.tab.active { color: var(--mint-deep); background: var(--mint-soft); }

/* ---------- Files ---------- */

.file-list, .result-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 8px;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: var(--text);
  transition: transform 0.12s ease;
}

.file-item:active { transform: scale(0.98); }

.file-icon {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: var(--purple-soft);
  color: var(--purple);
  font-size: 18px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-transform: uppercase;
}

.file-meta { flex: 1; min-width: 0; }

.file-name {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-sub { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

.file-download {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--mint-soft);
  color: var(--mint-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ---------- Memory search ---------- */

.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.search-bar input { flex: 1; background: var(--card); box-shadow: var(--shadow-sm); }

.btn-search { width: auto; padding: 13px 22px; }

.result-item {
  background: var(--card);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}

.result-file {
  font-size: 13px;
  font-weight: 700;
  color: var(--purple);
  display: flex;
  align-items: center;
  gap: 6px;
}

.result-line {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg);
  border-radius: var(--radius-pill);
  padding: 2px 8px;
}

.result-snippet {
  font-size: 15px;
  line-height: 1.5;
  margin-top: 8px;
  white-space: pre-wrap;
  word-break: break-word;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  font-size: 15px;
  padding: 40px 16px;
}

.loading-line {
  text-align: center;
  color: var(--text-muted);
  font-size: 15px;
  padding: 24px 16px;
}

/* ---------- Settings sheet ---------- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(28, 28, 30, 0.45);
  backdrop-filter: blur(2px);
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet {
  width: 100%;
  max-width: var(--max-width);
  max-height: 88dvh;
  overflow-y: auto;
  background: var(--card);
  border-radius: 28px 28px 0 0;
  padding: 12px 24px calc(28px + env(safe-area-inset-bottom));
  animation: sheet-up 0.25s ease;
}

@keyframes sheet-up {
  from { transform: translateY(40px); opacity: 0.6; }
  to { transform: translateY(0); opacity: 1; }
}

.sheet-handle {
  width: 40px;
  height: 5px;
  border-radius: var(--radius-pill);
  background: var(--border);
  margin: 0 auto 16px;
}

.sheet-title { font-size: 22px; font-weight: 800; margin-bottom: 20px; }

.sheet-section {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ---------- Desktop widening ---------- */

@media (min-width: 640px) {
  .view { padding: 24px 24px 16px; }
  .composer { padding-left: 24px; padding-right: 24px; }
  .sheet { border-radius: 28px; margin-bottom: 24px; }
  .msg { max-width: 75%; }
}
