/* ── Fraunces (display serif) — self-host, offline PWA. latin + latin-ext (TR). ── */
@font-face {
  font-family: 'Fraunces'; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url('/fonts/fraunces-normal-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: 'Fraunces'; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url('/fonts/fraunces-normal-latinext.woff2') format('woff2');
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face {
  font-family: 'Fraunces'; font-style: italic; font-weight: 400 500; font-display: swap;
  src: url('/fonts/fraunces-italic-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: 'Fraunces'; font-style: italic; font-weight: 400 500; font-display: swap;
  src: url('/fonts/fraunces-italic-latinext.woff2') format('woff2');
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}

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

:root {
  --bg: #f9f8f6;
  --bg-input: #ffffff;
  --bg-hover: #f0efed;
  --bg-chip: #f0efed;
  --bg-chip-active: #e8e0d8;
  --bg-badge: #f0efed;
  --bg-user-msg: #d4714c;
  --text: #1a1a1a;
  --text-2: #6b6560;
  --text-3: #9b9590;
  --accent: #d4714c;
  --ring: rgba(212, 113, 76, 0.22);
  --border: #e8e4e0;
  --border-focus: #d4714c;
  --composer-bg: #ffffff;
  --nav-track: #ece8e4;
  --nav-active: #ffffff;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-full: 9999px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif;
  --mono: 'SF Mono', 'Menlo', monospace;
  --display: 'Fraunces', Georgia, 'Times New Roman', serif;
  /* ── Semantik klinik şiddet skalası (sakin / dikkat / kritik) ──
     Warm palette'le harmonize — alarm değil, sinyal. high-alert ilaç,
     NEWS2 risk, "1 yıldan eski" uyarısı, durum rozetleri. */
  --sev-calm:        #3f7d5a;
  --sev-calm-bg:     #eef3ee;
  --sev-calm-border: #cfe0d3;
  --sev-caution:        #b5781f;
  --sev-caution-bg:     #f7f0e2;
  --sev-caution-border: #ecd9b0;
  --sev-critical:        #c0392b;
  --sev-critical-bg:     #f8ece9;
  --sev-critical-border: #eec9c3;
  /* ── Sıcak gölge elevation skalası — saf siyah değil, kahve-tonlu (clay). ── */
  --shadow-sm:  0 1px 2px rgba(60, 30, 15, 0.06), 0 1px 3px rgba(60, 30, 15, 0.08);
  --shadow-md:  0 2px 6px -1px rgba(60, 30, 15, 0.08), 0 8px 20px -6px rgba(60, 30, 15, 0.12);
  --shadow-lg:  0 4px 12px -2px rgba(60, 30, 15, 0.10), 0 18px 44px -10px rgba(60, 30, 15, 0.18);
  --shadow-pop: 0 -12px 32px rgba(60, 30, 15, 0.14);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #2d2925;
    --bg-input: #2d2925;
    --bg-hover: #38342f;
    --bg-chip: #38342f;
    --bg-chip-active: #443f3a;
    --bg-badge: #38342f;
    --bg-user-msg: #d4714c;
    --text: #ece8e4;
    --text-2: #a09a94;
    --text-3: #7a7470;
    --border: #4e4944;
    --border-focus: #d4714c;
    --composer-bg: #38342f;
    --nav-track: #38342f;
    --nav-active: #1e1c19;
    /* Şiddet skalası — dark için aydınlatılmış fg + düşük-opak tint */
    --sev-calm:        #7fb892;
    --sev-calm-bg:     rgba(127, 184, 146, 0.12);
    --sev-calm-border: rgba(127, 184, 146, 0.28);
    --sev-caution:        #d6a85a;
    --sev-caution-bg:     rgba(214, 168, 90, 0.12);
    --sev-caution-border: rgba(214, 168, 90, 0.28);
    --sev-critical:        #e0796b;
    --sev-critical-bg:     rgba(224, 121, 107, 0.14);
    --sev-critical-border: rgba(224, 121, 107, 0.32);
    /* Dark — derin, daha yüksek alpha (zemin koyu, gölge görünür olsun) */
    --shadow-sm:  0 1px 2px rgba(0, 0, 0, 0.30), 0 1px 3px rgba(0, 0, 0, 0.24);
    --shadow-md:  0 2px 6px -1px rgba(0, 0, 0, 0.36), 0 8px 22px -6px rgba(0, 0, 0, 0.44);
    --shadow-lg:  0 4px 14px -2px rgba(0, 0, 0, 0.42), 0 20px 56px -10px rgba(0, 0, 0, 0.56);
    --shadow-pop: 0 -12px 32px rgba(0, 0, 0, 0.40);
  }
}

html { font-size: 16px; height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

#app {
  max-width: 680px;
  margin: 0 auto;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ── Sidebar (mobile: bottom tab bar concept, but we keep it simple) ── */

/* ── Login (warm clinical editorial) ── */
.login {
  position: relative;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: 1.1fr auto 1.4fr;
  justify-items: center;
  padding: 24px;
}
/* Atmosfer — full-bleed (viewport'u kaplar, #app 680px sınırından bağımsız) */
.login-atmos { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; animation: login-glow 1.2s ease both; }
.login-atmos::before {
  content: ""; position: absolute; width: 120vmax; height: 120vmax;
  top: -55vmax; left: -35vmax; border-radius: 50%; filter: blur(8px);
  background: radial-gradient(circle at center, color-mix(in srgb, var(--accent) 22%, transparent) 0%, transparent 55%);
}
.login-atmos::after {
  content: ""; position: absolute; width: 90vmax; height: 90vmax;
  bottom: -45vmax; right: -30vmax; border-radius: 50%;
  background: radial-gradient(circle at center, color-mix(in srgb, #5b7a86 14%, transparent) 0%, transparent 60%);
}
.login-contour {
  position: absolute; inset: 0; opacity: .5;
  background-image: repeating-radial-gradient(circle at 18% 8%,
    transparent 0, transparent 58px,
    color-mix(in srgb, var(--accent) 8%, transparent) 58px,
    color-mix(in srgb, var(--accent) 8%, transparent) 59px,
    transparent 59px, transparent 118px);
  -webkit-mask-image: linear-gradient(120deg, #000 0%, transparent 55%);
  mask-image: linear-gradient(120deg, #000 0%, transparent 55%);
}
.login-grain {
  position: absolute; inset: 0; opacity: .035; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
@media (prefers-color-scheme: dark) { .login-grain { opacity: .05; } }

.login-stage { grid-row: 2; z-index: 1; width: 100%; max-width: 360px; display: flex; flex-direction: column; align-items: center; }
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-bottom: 30px; }
.login-logo { width: 132px; height: auto; display: block; }
.login-tagline {
  font-family: var(--display); font-optical-sizing: auto;
  font-weight: 400; font-style: italic; font-size: 1.0625rem;
  letter-spacing: .005em; color: var(--text-2); text-align: center;
}
.login-tagline b { font-style: normal; font-weight: 600; color: var(--accent); }
.login-greet {
  font-size: .75rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--text-3); margin-bottom: 18px;
}
.login-form { width: 100%; display: flex; flex-direction: column; gap: 11px; }
.login-fieldwrap { position: relative; display: flex; align-items: center; }
.login-fieldwrap svg {
  position: absolute; left: 15px; width: 17px; height: 17px;
  stroke: var(--text-3); fill: none; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round; transition: stroke .2s; pointer-events: none;
}
.login-field {
  width: 100%; background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 14px; padding: 14px 16px 14px 42px; color: var(--text);
  font-size: 1rem; font-family: var(--font); outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.login-field::placeholder { color: var(--text-3); }
.login-field:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--ring, rgba(212,113,76,.22)); }
.login-fieldwrap:focus-within svg { stroke: var(--accent); }
.login-btn {
  margin-top: 7px; border: none; border-radius: 14px; padding: 14px;
  background: linear-gradient(180deg, var(--accent) 0%, #b9572f 100%);
  color: #fff; font-size: .9375rem; font-weight: 600; letter-spacing: .01em;
  font-family: var(--font); cursor: pointer;
  box-shadow: 0 1px 2px rgba(120,50,20,.25), 0 6px 18px -6px rgba(120,50,20,.4);
  transition: transform .15s, box-shadow .2s, filter .2s;
}
.login-btn:hover { filter: brightness(1.04); box-shadow: 0 1px 2px rgba(120,50,20,.3), 0 10px 26px -6px rgba(120,50,20,.5); }
.login-btn:active { transform: translateY(1px); }
.login-btn:disabled { opacity: .6; cursor: default; }
.login-err { color: #c0392b; font-size: 0.8125rem; text-align: center; }
.login-foot {
  grid-row: 3; align-self: end; z-index: 1;
  font-size: .6875rem; letter-spacing: .06em; color: var(--text-3); text-align: center;
  display: flex; align-items: center; gap: 7px;
}
.login-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); opacity: .7; }

@keyframes login-glow { from { opacity: 0; } to { opacity: 1; } }
@keyframes login-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.login-brand, .login-greet, .login-fieldwrap, .login-btn, .login-foot {
  opacity: 0; animation: login-rise .7s cubic-bezier(.2,.7,.2,1) both;
}
.login-brand { animation-delay: .05s; }
.login-greet { animation-delay: .18s; }
.login-fieldwrap.lf1 { animation-delay: .28s; }
.login-fieldwrap.lf2 { animation-delay: .36s; }
.login-btn { animation-delay: .46s; }
.login-foot { animation-delay: .6s; }
@media (prefers-reduced-motion: reduce) {
  .login-atmos, .login-brand, .login-greet, .login-fieldwrap, .login-btn, .login-foot {
    animation: none !important; opacity: 1 !important; transform: none !important;
  }
}

/* ── Input (shared) ── */
.field {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  color: var(--text);
  font-size: 1rem;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.2s;
}
.field:focus { border-color: var(--border-focus); }
.field::placeholder { color: var(--text-3); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-full);
  padding: 11px 24px;
  font-size: 0.9375rem;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-primary:hover { opacity: 0.85; }
.btn-primary:disabled { opacity: 0.4; cursor: default; }

/* ── Home: Claude-style centered input ── */
.home {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  position: relative;
}
/* ── Home atmosfer — login'in sakin/hafif yankısı. Negatif alanda derinlik;
   yoğun liste görünümlerine taşınmaz (yalnız ferah ana ekran). ── */
/* full-bleed — login-atmos gibi viewport'u kaplar; #app 680px sınırından
   bağımsız (absolute olsaydı geniş ekranda yanlarda boşluk kalırdı). */
.app-atmos { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.app-atmos::before {
  content: ""; position: absolute; width: 80vmax; height: 80vmax;
  top: -46vmax; right: -30vmax; border-radius: 50%; filter: blur(6px);
  background: radial-gradient(circle at center, color-mix(in srgb, var(--accent) 12%, transparent) 0%, transparent 60%);
}
.app-atmos::after {
  content: ""; position: absolute; width: 64vmax; height: 64vmax;
  bottom: -40vmax; left: -28vmax; border-radius: 50%;
  background: radial-gradient(circle at center, color-mix(in srgb, #5b7a86 9%, transparent) 0%, transparent 62%);
}
.app-grain {
  position: absolute; inset: 0; opacity: .022; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
@media (prefers-color-scheme: dark) { .app-grain { opacity: .04; } }
.home-body {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  position: relative;
  z-index: 1;
}
.home-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.home-logo { width: 200px; height: auto; }
/* Dark: gerçek dark-variant SVG (lacivert wordmark→cream, kırmızı marka korunur).
   Eski brightness(0) invert(1) hack'i kırmızı markayı yok ediyordu. */
@media (prefers-color-scheme: dark) {
  .home-logo { content: url('/icons/logo-dark.svg'); }
}
.home-mark {
  font-family: var(--display);
  font-optical-sizing: auto;
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.005em;
  text-align: center;
}
.home-sub {
  font-size: 0.875rem;
  color: var(--text-3, var(--text-2));
  opacity: 0.7;
  margin-top: 8px;
  text-align: center;
  letter-spacing: 0;
  transition: opacity 0.2s ease;
}
.home-bottom {
  flex-shrink: 0;
  padding: 0 16px;
  padding-bottom: calc(16px + var(--safe-bottom));
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}
/* ── Orkestreli giriş — login-rise'ın home eşleniği. Yalnız hareket
   tercihi açıkken; reduce'da içerik anında görünür (opacity:0 kalmaz). ── */
@keyframes home-rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: no-preference) {
  .home-logo, .home-mark, .home-sub, .home-bottom {
    opacity: 0; animation: home-rise .6s cubic-bezier(.2,.7,.2,1) both;
  }
  .home-logo   { animation-delay: .04s; }
  .home-mark   { animation-delay: .13s; }
  .home-sub    { animation-delay: .21s; }
  .home-bottom { animation-delay: .30s; }
}
/* ── Composer (Claude-style input card + external pills) ── */
.composer { width: 100%; }

.composer-card {
  background: var(--composer-bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px 20px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-md);
  transition: box-shadow .25s, border-color .2s;
}
.composer-card:focus-within { box-shadow: var(--shadow-lg); border-color: var(--border-focus); }
.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.composer-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.0625rem;
  font-family: var(--font);
  outline: none;
  resize: none;
  line-height: 1.6;
  max-height: 200px;
  min-height: 72px;
}
.composer-input::placeholder { color: var(--text-3); }
.composer-send {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s;
  flex-shrink: 0;
}
.composer-send:disabled { opacity: 0.25; cursor: default; }

.composer-actions {
  display: flex;
  align-items: center;
  padding-top: 6px;
}
.composer-attach {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.composer-attach:hover { color: var(--text); background: var(--bg-chip); }

/* Sesli giriş — Web Speech API tetikleyici */
.composer-mic {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
  margin-right: 6px;
  -webkit-tap-highlight-color: transparent;
}
.composer-mic:hover { color: var(--text); background: var(--bg-chip); }
.composer-mic--on {
  color: #fff;
  background: #dc2626;
  animation: mic-pulse 1.6s ease-in-out infinite;
}
.composer-mic--on:hover { background: #b91c1c; color: #fff; }
@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.5); }
  50% { box-shadow: 0 0 0 8px rgba(220, 38, 38, 0); }
}

/* Quick replies — input boşken composer üstünde scrollable horizontal chip row */
.quickreplies {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 4px 10px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.quickreplies::-webkit-scrollbar { display: none; }
.quickreply {
  flex-shrink: 0;
  padding: 7px 14px;
  background: var(--bg-chip);
  color: var(--text-2);
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  font-family: var(--font);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.12s;
  -webkit-tap-highlight-color: transparent;
}
.quickreply:hover, .quickreply:active {
  background: var(--bg-chip-active);
  color: var(--text);
  border-color: var(--border);
}

/* ── Composer chip row (mod + hasta seçimi) ── */
.chip-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 4px 0;
}
.chip-wrap { position: relative; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px 7px 12px;
  background: var(--bg-chip);
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  color: var(--text);
  font-size: 0.875rem;
  font-family: var(--font);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.chip:hover { background: var(--bg-chip-active); }
.chip--open { background: var(--bg-chip-active); border-color: var(--border); }
.chip-icon { display: inline-flex; color: var(--text-2); }
.chip-icon svg { display: block; }
.chip-label { font-weight: 500; }
.chip-chevron { display: inline-flex; opacity: 0.55; margin-left: 2px; }
.chip-chevron svg { display: block; }

.chip-menu {
  position: absolute;
  /* Composer alt-sabit olduğu için menü yukarı açılır — aşağı taşma riski yok */
  bottom: calc(100% + 6px);
  min-width: 200px;
  max-width: 320px;
  max-height: 60vh;
  overflow-y: auto;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-pop);
  padding: 6px;
  z-index: 50;
  -webkit-overflow-scrolling: touch;
}
.chip-menu--left { left: 0; }
.chip-menu--right { right: 0; }
.chip-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.875rem;
  color: var(--text);
  cursor: pointer;
  transition: background 0.1s;
}
.chip-menu-item:hover { background: var(--bg-hover); }
.chip-menu-item--active { color: var(--accent); font-weight: 500; }
.chip-menu-item--muted { color: var(--text-3); }
.chip-menu-item-body { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.chip-menu-item-label { font-size: 0.875rem; }
.chip-menu-item-desc { font-size: 0.75rem; color: var(--text-3); }
.chip-menu-item-meta { margin-left: auto; font-size: 0.75rem; color: var(--text-3); }
.chip-menu-item-icon { display: inline-flex; color: var(--text-2); }
.chip-menu-item--active .chip-menu-item-icon { color: var(--accent); }
.chip-menu-divider { height: 1px; background: var(--border); margin: 4px 8px; }

@media (max-width: 420px) {
  /* Mobilde menü her zaman chip'in sol kenarından açılır — chip ekranın
     solunda olduğu için sağa hizalamak yaprağı dışarı taşıyor. */
  .chip-menu { min-width: 200px; max-width: calc(100vw - 24px); }
}

.attach-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}
.attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 12px;
  background: var(--bg-chip);
  border-radius: 12px;
  margin-bottom: 4px;
  width: fit-content;
  max-width: 100%;
  color: var(--text-2);
}
.attach-row .attach-chip { margin-bottom: 0; }
.attach-name {
  font-size: 0.8125rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}
.attach-remove {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.attach-remove:hover { background: var(--bg-chip-active); color: var(--text); }

/* ── Nav (Claude-style segmented control) ── */
.nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px 12px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
}
/* Home'da nav saydam — full-bleed atmosfer gradient'i üst nav'ın da arkasından
   kesintisiz aksın (home kaymaz; içerik nav altına girmez). nav-seg pill ve
   ikonlar kendi zeminleriyle okunur kalır. Liste route'larında nav opak kalır
   (kayan içeriği maskeler). */
.nav-top.nav-bare { background: transparent; }
@media (prefers-color-scheme: dark) {
  .login-logo { content: url('/icons/logo-dark.svg'); }
}
.nav-seg {
  display: inline-flex;
  align-items: center;
  background: var(--nav-track);
  border-radius: var(--radius-full);
  padding: 3px;
  gap: 2px;
  position: relative;
}
.nav-slider {
  position: absolute;
  top: 3px;
  left: 3px;
  height: calc(100% - 6px);
  border-radius: var(--radius-full);
  background: var(--nav-active);
  box-shadow: var(--shadow-sm);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 0;
}
.nav-item {
  padding: 7px 14px;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  color: var(--text-3);
  font-size: 0.8125rem;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: color 0.2s;
  white-space: nowrap;
  position: relative;
  z-index: 1;
}
@media (max-width: 420px) {
  .nav-item { padding: 6px 10px; font-size: 0.75rem; }
  .nav { padding: 8px 8px; gap: 2px; }
}
.nav-item:hover { color: var(--text-2); }
.nav-item--on { color: var(--text); }

.nav-logout {
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: color 0.15s;
  display: flex;
  align-items: center;
  margin-left: 12px;
  flex-shrink: 0;
}
.nav-logout:hover { color: var(--text-2); }

/* ── Bottom tab bar (mobile, native app pattern) ── */
.nav-bottom {
  display: none;
  flex-shrink: 0;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: 90;
}
.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px 6px;
  border: none;
  background: none;
  color: var(--text-3);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.6875rem;
  font-weight: 500;
  min-height: 52px;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s;
}
.nav-tab svg { width: 22px; height: 22px; }
.nav-tab--on { color: var(--accent); }
.nav-tab:active { background: var(--bg-chip); }
.nav-tab span {
  white-space: nowrap;
  letter-spacing: 0.01em;
}

/* Home sağ üst logout (mobile) */
.home-logout {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top, 0px));
  right: 14px;
  z-index: 50;
  background: none;
  border: none;
  padding: 8px;
  border-radius: 50%;
  color: var(--text-3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}
.home-logout:hover, .home-logout:active {
  color: var(--text);
  background: var(--bg-chip);
}

/* Responsive: mobile <768px bottom bar, desktop >=768px top */
@media (max-width: 767px) {
  .nav-top { display: none !important; }
  .nav-bottom { display: flex; }
}
@media (min-width: 768px) {
  .nav-bottom { display: none !important; }
  .home-logout { display: none; }
}

/* ── App Shell ── */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

/* ── Chat ── */
.chat {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.chat-back {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.875rem;
  font-family: var(--font);
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 3px;
  transition: opacity 0.15s;
}
.chat-back:hover { opacity: 0.7; }
.chat-back svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  -webkit-overflow-scrolling: touch;
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
}

.msg-u {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  margin: 8px 0;
}
.msg-u-inner {
  background: var(--bg-user-msg);
  color: #fff;
  border-radius: 20px 20px 6px 20px;
  padding: 10px 16px;
  font-size: 0.9375rem;
  max-width: 85%;
  line-height: 1.55;
}
.msg-u .msg-time {
  margin-top: 3px;
  padding-right: 8px;
}
.msg-time {
  font-size: 0.6875rem;
  color: var(--text-3);
  letter-spacing: 0.01em;
  user-select: none;
  margin-left: auto;
}
.msg-actions .msg-time { margin-left: auto; align-self: center; }
.msg-a {
  margin: 8px 0;
  padding: 6px 0;
  font-size: 0.9375rem;
  line-height: 1.7;
}
.thinking {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  margin: 8px 0;
  font-size: 0.8125rem;
  color: var(--text-3);
  background: var(--bg-chip);
  border-radius: var(--radius);
}
.think-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: blink 1.4s infinite;
}
@keyframes blink {
  0%, 80%, 100% { opacity: 0.2; }
  40% { opacity: 1; }
}

.chat-foot {
  padding: 10px 20px;
  padding-bottom: calc(10px + var(--safe-bottom));
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
}
.chat-card {
  padding: 16px 14px 14px 20px;
}
.chat-card .composer-input {
  min-height: 24px;
}

/* ── Vault ── */
.vault {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
}
/* Vault list header: search + filter chips birlikte sticky kalır — tag'ler
   sticky search'in altına kayıp kaybolmasın diye tek wrapper'da. History ve
   Patients listelerinde .vault-search wrapper'sız çalışır; o yüzden hem
   .vault-search hem .vault-header sticky-capable. */
.vault-header {
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 50;
}
.vault-search {
  padding: 8px 16px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 50;
}
.vault-header .vault-search { position: static; background: transparent; z-index: auto; }
.vault-search-box {
  position: relative;
}
.vault-search-box svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  stroke: var(--text-3);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.vault-search-box .field { padding-left: 38px; }

.vault-tags {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 4px 16px 10px;
  scrollbar-width: none;
}
.vault-tags::-webkit-scrollbar { display: none; }
.vtag {
  flex-shrink: 0;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  background: var(--bg-chip);
  color: var(--text-2);
  border: none;
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.15s;
  white-space: nowrap;
}
.vtag:hover { background: var(--bg-chip-active); }
.vtag-on { background: var(--accent); color: #fff; }

.vault-list { padding: 0 12px; }
.vault-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s;
}
.vault-row:hover { background: var(--bg-hover); }
.vault-row:active { opacity: 0.6; }
.vault-row-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-3);
  flex-shrink: 0;
}
.vault-row-body { flex: 1; min-width: 0; }
.vault-row-t { font-size: 0.9375rem; font-weight: 450; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vault-row-m { font-size: 0.75rem; color: var(--text-3); }

.vault-count {
  font-size: 0.75rem;
  color: var(--text-3);
  text-align: right;
  padding-top: 4px;
}
.vault-more {
  display: block;
  width: 100%;
  padding: 14px;
  margin: 8px 0 16px;
  background: var(--bg-chip);
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 0.875rem;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s;
}
.vault-more:hover { background: var(--bg-chip-active); color: var(--text); }

/* Topic detail */
.topic-detail { padding: 0 20px 32px; }
.topic-badges { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 12px; }
.tbadge {
  font-size: 0.6875rem;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: var(--bg-badge);
  color: var(--text-2);
  font-weight: 500;
}
.tbadge-ok { color: var(--sev-calm); }

/* ── Şiddet rozeti — dolgulu tint + ince kenar, ikon önekli. ── */
.sev-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  border: 1px solid transparent;
  letter-spacing: 0.01em;
}
.sev-badge::before { font-size: 0.75em; line-height: 1; }
.sev-critical {
  color: var(--sev-critical);
  background: var(--sev-critical-bg);
  border-color: var(--sev-critical-border);
}
.sev-caution {
  color: var(--sev-caution);
  background: var(--sev-caution-bg);
  border-color: var(--sev-caution-border);
}
.sev-calm {
  color: var(--sev-calm);
  background: var(--sev-calm-bg);
  border-color: var(--sev-calm-border);
}

.topic-date { font-size: 0.75rem; color: var(--text-3); margin-bottom: 16px; }
/* "1 yıldan eski" — CLAUDE.md kuralı: ⚠ ile dikkat sinyali. */
.topic-date.is-stale {
  color: var(--sev-caution);
  font-weight: 500;
}
.topic-date.is-stale::before { content: "⚠ "; }

/* ── Patient view (Vizit detay) ── */
.patient-view .patient-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 5;
}
.patient-actions-right {
  margin-left: auto;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.btn-primary, .btn-ghost, .btn-danger {
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover { opacity: 0.85; }
.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--bg-chip); }
.btn-danger {
  background: transparent;
  color: #dc2626;
  border-color: #dc2626;
}
.btn-danger:hover { background: rgba(220, 38, 38, 0.08); }
.btn-danger-confirm {
  background: #dc2626;
  color: #fff;
}
.btn-danger-confirm:hover { background: #b91c1c; }

/* Icon-only variant — square tap target, mobile öncelikli (44px iOS HIG) */
.btn-icon {
  padding: 0;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn-icon svg { display: block; }
@media (max-width: 600px) {
  .btn-icon { width: 44px; height: 44px; }
}

.patient-title {
  font-family: var(--display);
  font-optical-sizing: auto;
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 18px 0 10px;
  line-height: 1.2;
}
.patient-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 22px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.patient-meta-date {
  font-size: 0.8125rem;
  color: var(--text-3);
}

/* ── Notes editor (Benim Notlarım overlay) ── */
.notes-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.notes-modal {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.notes-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.notes-modal-header h3 {
  margin: 0;
  font-family: var(--display);
  font-optical-sizing: auto;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
}
.notes-textarea {
  flex: 1;
  min-height: 280px;
  resize: none;
  padding: 14px 18px;
  font-family: var(--mono);
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  border: none;
  outline: none;
  width: 100%;
  box-sizing: border-box;
}
.notes-modal-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.notes-charcount {
  font-size: 0.75rem;
  color: var(--text-3);
  margin-right: auto;
}
.notes-charcount.over { color: #dc2626; font-weight: 500; }
.notes-err {
  font-size: 0.8125rem;
  color: #dc2626;
}
@media (max-width: 600px) {
  .notes-overlay { padding: 0; }
  .notes-modal { border-radius: 0; max-height: 100vh; height: 100vh; }
}

/* ── Markdown ── */
.md h2 { font-family: var(--display); font-optical-sizing: auto; font-size: 1.15rem; font-weight: 600; margin: 22px 0 8px; letter-spacing: -0.005em; }
.md h3 { font-size: 0.9375rem; font-weight: 600; margin: 14px 0 6px; }
.md p { margin-bottom: 8px; }
.md ul, .md ol { margin: 6px 0; padding-left: 20px; }
.md li { margin-bottom: 3px; font-size: 0.9375rem; }
.md strong { font-weight: 600; }
.md a { color: var(--accent); text-decoration: none; }
/* Wikilink + skill link — asistan cevabındaki tıklanabilir referanslar */
.md a[href^="#wiki:"],
.md a[href^="#skill:"] {
  color: var(--accent);
  border-bottom: 1px dashed var(--accent);
  cursor: pointer;
  padding-bottom: 1px;
}
.md a[href^="#wiki:"]:hover,
.md a[href^="#skill:"]:hover {
  background: var(--bg-chip);
  border-bottom-style: solid;
}
.md code { background: var(--bg-chip); padding: 2px 6px; border-radius: 5px; font-size: 0.8125rem; font-family: var(--mono); }
.md pre { background: var(--bg-chip); padding: 14px; border-radius: var(--radius-sm); overflow-x: auto; margin: 10px 0; font-size: 0.8125rem; }
.md table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 0.8125rem; }
.md th, .md td { border: 1px solid var(--border); padding: 7px 10px; text-align: left; }
.md th { background: var(--bg-chip); font-weight: 600; }
.md blockquote { border-left: 3px solid var(--accent); padding-left: 12px; margin: 10px 0; color: var(--text-2); }
.md hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ── Assistant message actions (copy) ── */
.msg-a-wrap { display: flex; flex-direction: column; }
.msg-actions {
  display: flex;
  gap: 4px;
  margin-top: 2px;
  margin-bottom: 4px;
  padding-left: 2px;
}
.msg-copy {
  background: none;
  border: none;
  color: var(--text-3);
  padding: 5px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.75rem;
  font-family: var(--font);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.msg-copy:hover, .msg-copy:active { color: var(--text); background: var(--bg-chip); }
.msg-copy svg { flex-shrink: 0; }

/* ── History ── */
.history-detail {
  padding: 0 20px 32px;
  max-width: 600px;
  margin: 0 auto;
}
.history-detail-q {
  font-family: var(--display);
  font-optical-sizing: auto;
  font-size: 1.2rem;
  font-weight: 600;
  padding: 12px 0 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  color: var(--accent);
}
.history-detail-meta {
  font-size: 0.75rem;
  color: var(--text-3);
  padding-top: 16px;
  border-top: 1px solid var(--border);
  margin-top: 16px;
}
.history-delete {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
}
.history-delete:hover { background: var(--bg-chip); color: var(--text); }
.history-resume {
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.8125rem;
  font-weight: 600;
  padding: 7px 14px;
  cursor: pointer;
  transition: opacity 0.15s;
}
.history-resume:hover { opacity: 0.85; }
.history-thread-badge {
  background: var(--bg-chip);
  color: var(--accent);
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 0.6875rem;
  font-weight: 600;
}
.history-turn { margin-bottom: 24px; padding-bottom: 18px; border-bottom: 1px dashed var(--border); }
.history-turn:last-of-type { border-bottom: none; margin-bottom: 8px; }
.history-turn .history-detail-q { border-bottom: none; padding: 0 0 10px; margin-bottom: 8px; }
.history-clear {
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 0.75rem;
  font-family: var(--font);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}
.history-clear:hover { color: #ef4444; }

/* ── Utility ── */
.empty { text-align: center; padding: 48px 24px; color: var(--text-3); font-size: 0.875rem; }

/* ── Zengin boş durum — ikon kutusu + display başlık + ipucu ── */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  gap: 12px; padding: 64px 24px; text-align: center;
  animation: home-rise .5s cubic-bezier(.2,.7,.2,1) both;
}
.empty-state-icon {
  width: 54px; height: 54px; border-radius: 17px;
  display: grid; place-items: center;
  background: var(--bg-chip); color: var(--text-3);
  box-shadow: var(--shadow-sm);
}
.empty-state-icon svg { width: 26px; height: 26px; }
.empty-state-title {
  font-family: var(--display); font-optical-sizing: auto;
  font-size: 1.0625rem; font-weight: 500; color: var(--text-2);
}
.empty-state-hint {
  font-size: 0.8125rem; color: var(--text-3);
  max-width: 264px; line-height: 1.55;
}
.lifecycle-reasons { display:flex; gap:.4rem; flex-wrap:wrap; align-items:center; margin:.6rem 0; }
.lifecycle-label { font-size:.85rem; opacity:.7; }
.chip-btn { padding:.3rem .7rem; border-radius:999px; border:1px solid var(--border); background:transparent; cursor:pointer; font-size:.85rem; }
.chip-btn.chip-alt { border-style:dashed; }
.lifecycle-msg { margin:.6rem 0; padding:.6rem .8rem; border-radius:.5rem; font-size:.9rem; }
.lifecycle-busy { opacity:.7; }
.lifecycle-warn { background: var(--sev-caution-bg); color: var(--sev-caution); }
.lifecycle-pii { background: var(--sev-critical-bg); color: var(--sev-critical); }
.pii-findings { width:100%; margin-top:.5rem; font-size:.8rem; border-collapse:collapse; }
.pii-findings th, .pii-findings td { border:1px solid var(--border); padding:.2rem .4rem; text-align:left; }
