/* Premium, restrained palette — same design language as select.hr-elenich.ru
   (warm paper + ink + one bronze accent, Lora for display type, Inter for body),
   tuned up a notch: deeper ink for contrast, hairline borders, shadows reserved
   for genuine elevation moments only, smooth-but-quiet transitions. One accent
   color, used sparingly — restraint is what reads as expensive, not ornament. */
:root {
  --paper: #f5f2eb;
  --card: #fcfbf7;
  --ink: #14181f;
  --ink-soft: #3c4452;
  --muted: #8a8580;
  --line: #e7e0cf;
  --line-2: #d2c7ab;
  --accent: #8a6a3b;
  --accent-ink: #6f5430;
  --ok: #3f7d56;
  --danger: #b3432f;
  --radius: 14px;
  --radius-sm: 9px;
  /* layered, diffuse shadows read as premium; one heavy shadow reads cheap */
  --shadow-rest: 0 1px 2px rgba(20, 24, 31, 0.04);
  --shadow-elevate: 0 2px 4px rgba(20, 24, 31, 0.04), 0 16px 32px -12px rgba(20, 24, 31, 0.14);
  --shadow-card: 0 1px 2px rgba(20, 24, 31, 0.03), 0 8px 24px -10px rgba(20, 24, 31, 0.08);
  --ease: cubic-bezier(.4, 0, .2, 1);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  /* Safety net: a mobile app screen should never scroll horizontally as a whole —
     any inner element that overflows should scroll internally instead (see #tabbar's
     min-width:0 fix below for the actual root cause found on a real iPhone). */
  overflow-x: hidden;
}

.serif { font-family: 'Lora', Georgia, serif; }

.ypa {
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

.view { display: flex; flex-direction: column; flex: 1; overflow: hidden; }
.view.hidden, .hidden { display: none !important; }

/* ---- brand mark — Яша's own illustrated character (a warm, friendly accent
   against the otherwise flat/minimal palette — deliberate, per Filip's choice to
   keep the rest of the app's restrained look and let the avatar carry the
   personality on its own, 2026-07-01). Not Yulia's photo — corrected earlier the
   same day after that wrongly implied the assistant's identity WAS Yulia. */
.brand-mark {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  border: 1px solid var(--line-2);
  background: var(--card) url('/img/yasha-avatar.jpg') center 42% / 108% no-repeat;
  box-shadow: var(--shadow-rest);
  margin: 0 auto 16px;
  overflow: hidden;
}
.brand-mark--sm { width: 46px; height: 46px; margin: 0; }

/* ---- login ---- */
.login-screen { align-items: center; justify-content: center; padding: 24px; }
.login-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 42px 34px;
  width: 100%;
  max-width: 360px;
  text-align: center;
}
.login-card h1 { font-family: 'Lora', serif; font-size: 25px; font-weight: 600; letter-spacing: -.01em; margin: 0; }
.login-card .subtitle { color: var(--muted); font-size: 13px; letter-spacing: .03em; margin: 6px 0 28px; }
.login-card input { width: 100%; margin-bottom: 12px; text-align: left; }
.error { color: var(--danger); font-size: 13px; margin-top: 6px; }

/* ---- inputs / buttons ---- */
input {
  font-family: inherit;
  font-size: 16px; /* prevents iOS Safari zoom-on-focus */
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-2);
  background: var(--paper);
  color: var(--ink);
  outline: none;
  transition: border-color .15s var(--ease);
}
input:focus { border-color: var(--accent); }

.btn {
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  transition: background .18s var(--ease), border-color .18s var(--ease), transform .05s var(--ease);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--ink); color: #fff; box-shadow: var(--shadow-rest); }
.btn-primary:hover { background: #232a36; }
.btn-accent { background: var(--accent); color: #fff; box-shadow: var(--shadow-rest); }
.btn-accent:hover { background: var(--accent-ink); }
.btn-block { width: 100%; }

.btn-send {
  width: 44px; height: 44px; flex: none;
  border-radius: 50%;
  border: none;
  background: var(--ink);
  color: #fff;
  font-size: 17px;
  cursor: pointer;
  box-shadow: var(--shadow-rest);
  transition: background .18s var(--ease), transform .12s var(--ease);
}
.btn-send:hover { background: var(--accent); }
.btn-send:active { transform: scale(.94); }

.btn-attach {
  width: 44px; height: 44px; flex: none;
  border-radius: 50%;
  border: 1px solid var(--line-2);
  background: var(--card);
  color: var(--ink-soft);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color .15s var(--ease), color .15s var(--ease), background .15s var(--ease);
}
.btn-attach:hover { border-color: var(--accent); color: var(--accent); background: var(--paper); }

.btn-mic {
  width: 44px; height: 44px; flex: none;
  border-radius: 50%;
  border: 1px solid var(--line-2);
  background: var(--card);
  color: var(--ink-soft);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color .15s var(--ease), color .15s var(--ease), background .15s var(--ease);
}
.btn-mic:hover { border-color: var(--accent); color: var(--accent); background: var(--paper); }
.btn-mic:disabled { opacity: .5; cursor: default; }
.btn-mic.recording {
  border-color: var(--danger);
  color: var(--danger);
  background: rgba(200, 60, 60, .08);
  animation: mic-pulse 1.2s ease-in-out infinite;
}
@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(200, 60, 60, .35); }
  50% { box-shadow: 0 0 0 8px rgba(200, 60, 60, 0); }
}

/* ---- icon buttons (menu, drawer close) ---- */
.icon-btn {
  width: 34px; height: 34px; flex: none;
  border-radius: 50%;
  border: none;
  background: none;
  color: var(--ink-soft);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  line-height: 1;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.icon-btn:hover { background: var(--card); color: var(--ink); }

/* ---- drawer (Projects + Sessions) — same slide-in pattern as select.hr-elenich.ru ---- */
.drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(20, 24, 31, .35);
  z-index: 40;
  opacity: 1;
  transition: opacity .2s var(--ease);
}
.drawer-overlay.hidden { display: none; }
.drawer {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: min(300px, 84vw);
  background: var(--paper);
  border-right: 1px solid var(--line);
  z-index: 50;
  padding: 18px 16px;
  padding-top: calc(18px + env(safe-area-inset-top));
  display: flex;
  flex-direction: column;
  gap: 8px;
  transform: translateX(-100%);
  transition: transform .25s var(--ease);
  overflow-y: auto;
}
.drawer.open { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.drawer-head--sub { margin-top: 18px; }
.drawer-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.drawer-list li {
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  cursor: pointer;
  color: var(--ink-soft);
  transition: background .15s var(--ease), color .15s var(--ease);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.drawer-list li:hover { background: var(--card); }
.drawer-list li.active { background: var(--card); color: var(--ink); font-weight: 600; border: 1px solid var(--line); }

.btn-ghost-sm {
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 4px;
  text-align: left;
  transition: color .15s var(--ease);
}
.btn-ghost-sm:hover { color: var(--accent-ink); }

/* ---- topbar / tabs ---- */
#topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-name { font-family: 'Lora', serif; font-weight: 600; font-size: 15.5px; line-height: 1.15; }
.brand-sub { display: block; font-family: 'Inter', sans-serif; font-weight: 400; font-size: 11px; color: var(--muted); letter-spacing: .02em; }

#tabbar {
  display: flex;
  gap: 4px;
  margin-left: auto;
  overflow-x: auto;
  /* Flex items default to min-width:auto (never shrink below content size) — without
     this, on a narrow iPhone the 4 tabs (Чат/Календарь/Задачи/Память) push #topbar
     wider than the screen instead of scrolling internally, cropping "Память" off the
     right edge with no way to reach it. Confirmed live on a real iPhone 2026-07-01. */
  min-width: 0;
  flex-shrink: 1;
  scrollbar-width: none; /* keep the scroll affordance invisible, iOS/Android touch-scroll still works */
}
#tabbar::-webkit-scrollbar { display: none; }
#tabbar button {
  flex: none; /* don't let individual tab buttons shrink/wrap their own text */
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--muted);
  background: none;
  border: none;
  padding: 8px 14px;
  border-radius: 20px;
  cursor: pointer;
  transition: color .15s var(--ease), background .15s var(--ease);
}
#tabbar button:hover { color: var(--ink); }
#tabbar button.active { color: var(--ink); background: var(--card); border: 1px solid var(--line); font-weight: 600; box-shadow: var(--shadow-rest); }

#main-views { flex: 1; overflow: hidden; display: flex; }
#main-views .view { padding: 18px; }

/* ---- section headings ---- */
.section-head { margin-bottom: 18px; }
.eyebrow {
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.eyebrow::before { content: ""; width: 18px; height: 1px; background: var(--accent); display: inline-block; }
.section-head h2 { font-family: 'Lora', serif; font-size: 22px; font-weight: 600; margin: 6px 0 0; }

/* ---- chat ---- */
#chat-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding-bottom: 8px; }

.msg {
  max-width: 78%;
  padding: 12px 17px;
  border-radius: 17px;
  line-height: 1.5;
  font-size: 14.5px;
}
.msg.user { align-self: flex-end; background: var(--ink); color: #fff; border-bottom-right-radius: 4px; box-shadow: var(--shadow-rest); }
.msg.assistant { align-self: flex-start; background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 4px; box-shadow: var(--shadow-rest); }

/* Markdown rendered inside an assistant bubble (see renderMarkdown in app.js) —
   reset default browser spacing so paragraphs/lists sit naturally inside the bubble. */
.msg.assistant p { margin: 0 0 8px; }
.msg.assistant p:last-child { margin-bottom: 0; }
.msg.assistant ul, .msg.assistant ol { margin: 0 0 8px; padding-left: 20px; }
.msg.assistant ul:last-child, .msg.assistant ol:last-child { margin-bottom: 0; }
.msg.assistant li { margin-bottom: 3px; }
.msg.assistant strong { font-weight: 600; color: var(--ink); }
.msg.assistant code {
  background: var(--paper);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 13px;
}

.file-delivery { padding: 10px 14px; }
.file-download-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--accent-ink);
  font-weight: 600;
  font-size: 13.5px;
  text-decoration: none;
  transition: color .15s var(--ease);
}
.file-download-link:hover { color: var(--accent); }

#upload-pending { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--card);
  border: 1px solid var(--line-2);
  border-radius: 20px;
  padding: 6px 8px 6px 12px;
  font-size: 12.5px;
  color: var(--ink-soft);
}
.attachment-chip svg { color: var(--accent); flex: none; }
.remove-attachment {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 15px; line-height: 1; padding: 2px 4px;
}
.remove-attachment:hover { color: var(--danger); }

#chat-form { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
#chat-input { flex: 1; }

#pending-confirmations { display: flex; flex-direction: column; gap: 10px; }
.confirm-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 13.5px;
}
.confirm-card pre {
  background: var(--paper);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--ink-soft);
  overflow-x: auto;
  margin: 8px 0;
}
.confirm-card .actions { display: flex; gap: 8px; margin-top: 4px; }
.confirm-card .approve { background: var(--ok); color: #fff; border: none; border-radius: var(--radius-sm); padding: 8px 16px; font-weight: 600; cursor: pointer; font-size: 13px; }
.confirm-card .reject { background: none; color: var(--danger); border: 1px solid var(--danger); border-radius: var(--radius-sm); padding: 8px 16px; font-weight: 600; cursor: pointer; font-size: 13px; }

/* ---- forms (calendar/tasks/memory) ---- */
.inline-form { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.inline-form input[type="text"] { flex: 1; min-width: 160px; }
.inline-form select {
  font-family: inherit;
  font-size: 14px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-2);
  background: var(--paper);
  color: var(--ink);
}
.memory-form input[type="text"]#memory-title { flex: 0 1 160px; min-width: 120px; }
.memory-form input[type="text"]#memory-content { flex: 2 1 220px; }
.memory-list-item-type {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--accent);
  font-weight: 700;
  display: block;
  margin-bottom: 2px;
}

/* ---- card lists ---- */
.card-list { list-style: none; padding: 0; margin: 0; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 10px; }
.card-list li {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 17px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  box-shadow: var(--shadow-rest);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease), transform .2s var(--ease);
}
.card-list li:hover { border-color: var(--line-2); box-shadow: var(--shadow-elevate); transform: translateY(-1px); }
.card-list li button {
  background: none;
  border: 1px solid var(--line-2);
  border-radius: 50%;
  width: 28px; height: 28px;
  cursor: pointer;
  color: var(--ok);
  font-size: 13px;
  transition: border-color .15s var(--ease);
}
.card-list li button:hover { border-color: var(--ok); }

/* ---- install banner ---- */
#install-banner {
  background: var(--ink);
  color: #d8c79a;
  text-align: center;
  padding: 10px 16px;
  font-size: 12.5px;
  letter-spacing: .01em;
}
