/* Eagly — editorial design system per Creative Direction:
   Quiet. Intentional. Restorative.
   Warm Ivory backgrounds · Deep Charcoal text (never pure black)
   Sedona Clay / Olive Sage accents · Cormorant Garamond + DM Sans */
:root {
  --ivory: #f4ede0;
  --ivory-deep: #ede4d2;
  --paper: #faf6ec;
  --sand: #e7dcc5;
  --clay: #a9613c;
  --clay-soft: #c08260;
  --sage: #7f8163;
  --charcoal: #2e2a25;
  --charcoal-soft: #6b6357;
  --line: rgba(169, 97, 60, 0.28);
  --line-soft: rgba(46, 42, 37, 0.12);
  --serif: "Cormorant Garamond", "Cormorant", Georgia, "Times New Roman", serif;
  --sans: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--ivory);
  color: var(--charcoal);
  font-family: var(--sans);
  font-size: 15.5px;
  font-weight: 300;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
.view { min-height: 100dvh; display: flex; flex-direction: column; }
#app-view, #brain-view { height: 100dvh; overflow: hidden; }
[hidden] { display: none !important; }

/* ===== Login — editorial split ===== */
#login-view { flex-direction: row; background: var(--ivory); }
.login-photo {
  flex: 0 0 42%;
  min-height: 100dvh;
  background: var(--ivory-deep);
  border-right: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.slideshow {
  position: relative;
  width: min(320px, 72%);
  aspect-ratio: 320 / 390;
}
.slide {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover;
  border-radius: 3px;
  box-shadow: 0 22px 60px rgba(46, 42, 37, 0.22);
  opacity: 0;
  transition: opacity 2s ease;
}
.slide.active { opacity: 1; }
.login-panel {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 48px 28px;
}
.login-card { width: 100%; max-width: 360px; text-align: center; }
.logo { height: 92px; margin: 0 auto 10px; display: block; }
.login-card h1 {
  font-family: var(--serif); font-size: 54px; font-weight: 500;
  letter-spacing: 0.14em; color: var(--charcoal);
}
.login-card .sub {
  color: var(--clay); font-size: 11px; letter-spacing: 0.28em;
  text-transform: uppercase; margin: 12px 0 40px; line-height: 2;
}
#login-form { text-align: left; display: flex; flex-direction: column; gap: 6px; }
#login-form label {
  font-size: 10px; letter-spacing: 0.24em; text-transform: uppercase;
  color: var(--charcoal-soft); margin-top: 16px;
}
#login-form input {
  background: var(--paper); border: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line);
  border-radius: 2px; padding: 13px 14px; color: var(--charcoal);
  font-size: 16px; font-family: var(--sans); outline: none; transition: border-color .25s;
}
#login-form input:focus { border-color: var(--clay); }
#login-btn {
  margin-top: 34px; padding: 15px;
  background: var(--clay); color: var(--paper);
  border: none; border-radius: 2px;
  font-family: var(--sans); font-size: 12px; letter-spacing: 0.26em; text-transform: uppercase;
  cursor: pointer; transition: background .25s;
}
#login-btn:hover { background: #8f4f30; }
.error { color: #a03d2e; font-size: 14px; margin-top: 14px; text-align: center; }
.login-quote {
  margin-top: 48px; font-family: var(--serif); font-style: italic;
  font-size: 18px; color: var(--sage); line-height: 1.8;
}

/* ===== Topbar ===== */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px; padding-top: max(10px, env(safe-area-inset-top));
  background: rgba(244, 237, 224, 0.94); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { height: 44px; }
.brand-glyph { color: var(--clay); display: grid; place-items: center; }
.brand-glyph svg { width: 26px; height: 26px; }
.brand strong {
  font-family: var(--serif); font-size: 21px; font-weight: 500;
  letter-spacing: 0.12em; display: block; line-height: 1.1; color: var(--charcoal);
}
.brand small {
  color: var(--clay); font-size: 9px; letter-spacing: 0.24em; text-transform: uppercase;
}
.topbar-actions { display: flex; gap: 6px; }
.ghost {
  background: transparent; border: none; border-bottom: 1px solid transparent;
  color: var(--charcoal-soft); padding: 7px 10px;
  font-family: var(--sans); font-size: 11.5px; letter-spacing: 0.14em; text-transform: uppercase;
  cursor: pointer; transition: all .25s; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
}
.ghost svg { width: 14px; height: 14px; flex: 0 0 auto; }
.ghost:hover { color: var(--clay); border-bottom-color: var(--clay); }

/* ===== Chat ===== */
.chat { flex: 1; overflow-y: auto; padding: 30px 18px 12px; width: 100%; max-width: 820px; margin: 0 auto; }
.welcome { text-align: center; padding: 3vh 8px 24px; }
.daily-card {
  width: min(260px, 62vw); border-radius: 3px; display: block; margin: 0 auto 30px;
  box-shadow: 0 18px 50px rgba(46, 42, 37, 0.18);
}
.welcome h2 {
  font-family: var(--serif); font-weight: 500; font-size: 36px;
  letter-spacing: 0.05em; color: var(--charcoal);
}
.welcome-sub { color: var(--charcoal-soft); margin: 12px 0 30px; font-size: 15px; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.chip {
  background: transparent; color: var(--charcoal);
  border: 1px solid var(--line); border-radius: 0;
  padding: 10px 18px; font-family: var(--sans); font-size: 13px; font-weight: 300;
  letter-spacing: 0.04em; cursor: pointer; transition: all .25s;
  display: inline-flex; align-items: center; gap: 8px;
}
.chip svg { width: 15px; height: 15px; flex: 0 0 auto; color: var(--clay); }
.chip:hover { border-color: var(--clay); background: var(--paper); }

.msg { margin: 22px 0; display: flex; gap: 12px; }
.msg .avatar {
  flex: 0 0 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
}
.msg .avatar svg { width: 17px; height: 17px; }
.msg.user { flex-direction: row-reverse; }
.msg.user .avatar { background: var(--sand); color: var(--charcoal-soft); }
.msg.eagly .avatar { background: var(--clay); color: var(--paper); }
.bubble { max-width: 84%; padding: 16px 20px; overflow-wrap: break-word; }
.msg.user .bubble {
  background: var(--sand); border-radius: 3px;
  white-space: pre-wrap; font-size: 15px;
}
.msg.eagly .bubble {
  background: var(--paper); border: 1px solid var(--line-soft);
  border-left: 2px solid var(--clay); border-radius: 3px;
}

/* markdown inside eagly bubbles */
.bubble h1, .bubble h2, .bubble h3 {
  font-family: var(--serif); font-weight: 600; color: var(--clay);
  margin: 16px 0 6px; line-height: 1.3; letter-spacing: 0.02em;
}
.bubble h1 { font-size: 23px; } .bubble h2 { font-size: 20px; } .bubble h3 { font-size: 17.5px; }
.bubble p { margin: 8px 0; }
.bubble ul, .bubble ol { margin: 8px 0 8px 20px; }
.bubble li { margin: 4px 0; }
.bubble blockquote {
  border-left: 2px solid var(--sage); margin: 12px 0; padding: 4px 16px;
  font-family: var(--serif); font-style: italic; font-size: 18px; color: var(--sage);
}
.bubble code {
  background: var(--ivory-deep); border-radius: 3px; padding: 1px 6px;
  font-size: 13px; color: var(--charcoal);
}
.bubble pre {
  background: var(--ivory-deep); border: 1px solid var(--line-soft);
  border-radius: 3px; padding: 12px; overflow-x: auto; margin: 10px 0;
}
.bubble pre code { background: none; padding: 0; }
.bubble .tbl-wrap { overflow-x: auto; margin: 12px 0; }
.bubble table { border-collapse: collapse; font-size: 13px; min-width: 420px; }
.bubble th, .bubble td { border: 1px solid var(--line-soft); padding: 7px 10px; text-align: left; vertical-align: top; }
.bubble th {
  background: var(--ivory-deep); color: var(--clay);
  font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; font-size: 11px;
}
.bubble hr { border: none; border-top: 1px solid var(--line); margin: 16px 0; }
.bubble a { color: var(--clay); }
.bubble strong { font-weight: 500; color: var(--charcoal); }
.bubble .md-img {
  display: block; max-width: 100%; max-height: 420px;
  border-radius: 3px; margin: 12px 0;
  box-shadow: 0 14px 40px rgba(46, 42, 37, 0.18);
}

.typing { display: inline-flex; gap: 5px; padding: 6px 2px; }
.typing i { width: 5px; height: 5px; border-radius: 50%; background: var(--clay); animation: breathe 1.4s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes breathe { 0%, 100% { opacity: .2; transform: scale(.85);} 50% { opacity: 1; transform: scale(1);} }

/* ===== Composer ===== */
.composer {
  display: flex; gap: 10px; align-items: flex-end;
  padding: 14px 18px; padding-bottom: max(14px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); background: var(--ivory);
  width: 100%; max-width: 820px; margin: 0 auto;
}
#input {
  flex: 1; resize: none; max-height: 160px;
  background: var(--paper); border: 1px solid var(--line-soft);
  border-radius: 3px; padding: 13px 16px; color: var(--charcoal);
  font-size: 16px; font-family: var(--sans); font-weight: 300; outline: none; line-height: 1.5;
}
#input:focus { border-color: var(--clay); }
#send-btn {
  flex: 0 0 46px; height: 46px; border-radius: 50%;
  background: var(--clay); color: var(--paper);
  border: none; cursor: pointer; transition: background .25s;
  display: grid; place-items: center;
}
#send-btn svg { width: 18px; height: 18px; }
#send-btn:hover { background: #8f4f30; }
#send-btn:disabled { opacity: .35; cursor: default; }

/* ===== Brain ===== */
.brain-main { flex: 1; overflow-y: auto; width: 100%; max-width: 700px; margin: 0 auto; padding: 30px 18px 48px; }
.brain-intro { color: var(--charcoal-soft); margin-bottom: 20px; }
.upload-zone {
  display: grid; place-items: center; min-height: 110px;
  border: 1px dashed var(--clay); border-radius: 3px;
  color: var(--clay); cursor: pointer; transition: background .25s;
  margin-bottom: 14px; text-align: center; padding: 12px;
  font-size: 13px; letter-spacing: 0.08em;
}
.upload-zone:hover, .upload-zone.drag { background: var(--paper); }
.upload-zone span { display: inline-flex; align-items: center; gap: 9px; }
.upload-zone svg { width: 18px; height: 18px; }
.paste-box summary svg { width: 14px; height: 14px; vertical-align: -2px; margin-right: 7px; }
.brain-status { margin: 10px 0; color: var(--clay); font-size: 14px; }
.paste-box { margin: 14px 0; border: 1px solid var(--line-soft); border-radius: 3px; padding: 12px 14px; background: var(--paper); }
.paste-box summary { cursor: pointer; color: var(--sage); font-size: 13.5px; letter-spacing: 0.04em; }
.paste-box input, .paste-box textarea {
  width: 100%; margin-top: 10px; background: var(--ivory);
  border: 1px solid var(--line-soft); border-radius: 3px; padding: 10px 12px;
  color: var(--charcoal); font-size: 14px; font-family: var(--sans); outline: none;
}
.paste-box input:focus, .paste-box textarea:focus { border-color: var(--clay); }
.paste-box button { margin-top: 10px; border: 1px solid var(--line); }
.brain-main h3 {
  font-family: var(--serif); font-weight: 600; color: var(--clay);
  margin: 30px 0 10px; font-size: 19px; letter-spacing: 0.06em;
}
.doc-list { list-style: none; }
.doc-list li {
  background: var(--paper); border: 1px solid var(--line-soft);
  border-radius: 3px; padding: 10px 14px; margin: 7px 0;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  font-size: 14px;
}
.doc-list.built-in li { color: var(--charcoal-soft); background: transparent; }
.doc-list .muted { color: var(--charcoal-soft); background: transparent; border: none; }
.doc-del { background: none; border: none; color: var(--charcoal-soft); cursor: pointer; font-size: 15px; }
.doc-del:hover { color: #a03d2e; }

@media (max-width: 420px) {
  .brand-logo { display: none; }
  .topbar { padding-left: 12px; padding-right: 12px; }
  .topbar-actions { gap: 2px; }
  .ghost { padding: 6px 7px; font-size: 10.5px; letter-spacing: 0.08em; }
}

@media (max-width: 760px) {
  #login-view { flex-direction: column; }
  .login-photo {
    flex: 0 0 34vh; min-height: 34vh;
    border-right: none; border-bottom: 1px solid var(--line);
    padding: 18px 0;
  }
  .slideshow { width: auto; height: calc(34vh - 36px); aspect-ratio: 320 / 390; }
  .login-panel { padding: 34px 24px 48px; }
  .logo { height: 74px; }
  .login-card h1 { font-size: 44px; }
  .bubble { max-width: 88%; }
  .brand small { display: none; }
  .brand-logo { height: 38px; }
  .welcome h2 { font-size: 29px; }
}
