:root {
  --bg: #f6efe4;
  --ink: #2b2a24;
  --muted: #7a7366;
  --card: #fffaf1;
  --line: #e4d8c3;
  --leaf: #4f6b3a;
  --warn: #b5532f;
  --serif: "New York", Georgia, "Times New Roman", serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c211a;
    --ink: #efe8d8;
    --muted: #9a9684;
    --card: #262d23;
    --line: #38412f;
    --leaf: #a9c58a;
    --warn: #e58a62;
  }
}
* { box-sizing: border-box; }
html { background: var(--bg); height: 100%; }
body {
  margin: 0;
  height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.5 -apple-system, system-ui, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  position: fixed; /* iOS'ta gövde kaymasın */
  inset: 0;
}
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
h1 {
  margin: 0;
  font: 700 2rem/1 var(--serif);
  letter-spacing: -0.02em;
  color: var(--leaf);
}
h1::after {
  content: "";
  display: block;
  width: 2rem;
  height: 3px;
  margin-top: 0.5rem;
  border-radius: 2px;
  background: var(--warn);
}
h2 { margin: 0; }
p { margin: 0; }
input, textarea, button { font: inherit; font-size: 16px; color: inherit; }
input, textarea {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.65rem 0.9rem;
  min-height: 44px;
  width: 100%;
  outline: none;
}
input:focus, textarea:focus { border-color: var(--leaf); }
button {
  min-height: 44px;
  min-width: 44px;
  padding: 0 1.1rem;
  border: 0;
  border-radius: 14px;
  background: var(--leaf);
  color: var(--bg);
  font-weight: 600;
  flex-shrink: 0;
}
button:disabled { opacity: 0.5; }
button:focus-visible { outline: 2px solid var(--warn); outline-offset: 2px; }
.ghost { background: transparent; color: var(--leaf); }
.ghost.icon { font-size: 1.6rem; line-height: 1; padding: 0; color: var(--muted); }
.error { margin: 0; min-height: 1.5em; color: var(--warn); font-size: 15px; }
.error:empty { display: none; }
.quiet { color: var(--muted); font-size: 15px; }

#login-view, #home-view { height: 100%; }
.login {
  max-width: 24rem;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 14vh) 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}
.login h1 { font-size: 3.5rem; margin-bottom: 1rem; }

/* Ana ekran: tek kaydırma alanı, yazma alanı altta çekmece gibi */
#home-view { position: relative; max-width: 40rem; margin: 0 auto; }
#scroller {
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  /* Çekmece açıkken son kart da çekmecenin üstüne çıkabilsin */
  padding: 0 16px max(calc(env(safe-area-inset-bottom) + 112px), calc(var(--sheet-h, 0px) + 16px));
}
.top {
  position: sticky;
  top: 0;
  z-index: 2;
  margin: 0 -16px 8px;
  padding: calc(env(safe-area-inset-top) + 10px) 20px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.top h1 { font-size: 1.7rem; }

.note {
  margin: 12px 0;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--warn);
  border-radius: 14px;
  font-size: 15px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  overflow-wrap: anywhere;
}

.morning-bar {
  margin: 12px 0 0;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.morning-text { min-width: 0; font-size: 15px; color: var(--muted); overflow-wrap: anywhere; }
.morning-edit { margin-right: -10px; padding: 0 10px; font-size: 15px; font-weight: 600; }
.morning-bar + .next { margin-top: 6px; }

.eyebrow {
  font: 600 12px/1.2 -apple-system, system-ui, sans-serif;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.next { margin: 18px 0 6px; display: flex; flex-direction: column; gap: 6px; }
.next-list { list-style: none; margin: 0; padding: 0; }
.next-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 12px;
  min-height: 52px;
  padding: 4px 0;
  border-bottom: 1px solid var(--line);
}
.next-item:last-child { border-bottom: 0; }
.next-txt { flex: 1 1 11rem; min-width: 0; }
.next-title { font-size: 16px; font-weight: 500; line-height: 1.35; overflow-wrap: anywhere; }
.next-when { font-size: 14px; line-height: 1.35; color: var(--muted); }
.cancel-btn {
  flex-shrink: 0;
  margin-right: -10px;
  padding: 0 10px;
  font-size: 15px;
  font-weight: 500;
  color: var(--muted);
}
.cancel-btn.armed { color: var(--warn); font-weight: 600; }
.more { align-self: flex-start; margin-left: -10px; padding: 0 10px; font-size: 15px; font-weight: 600; }
.next .error { margin-top: 2px; overflow-wrap: anywhere; }

.day {
  margin: 24px 0 10px;
  font: italic 400 1.05rem/1.2 var(--serif);
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 12px;
}
.day::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.card {
  margin-bottom: 12px;
  padding: 14px 16px 2px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  scroll-margin-top: 84px;
  scroll-margin-bottom: calc(var(--sheet-h, 0px) + 12px);
}
.card.notification, .card.morning { border-left: 3px solid var(--leaf); }
.card.flash { animation: flash 2.4s ease-out; }
@keyframes flash {
  0%, 35% { box-shadow: 0 0 0 3px var(--leaf); }
  100% { box-shadow: 0 0 0 3px transparent; }
}
.from-you { color: var(--muted); font-size: 15px; margin-bottom: 6px; }
.who { font-weight: 600; font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.main { font: 400 1.12rem/1.5 var(--serif); }
.rem-title {
  margin: 0 0 6px;
  font: 700 1.3rem/1.25 var(--serif);
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}
.has-rem .main, .morning .main { font-size: 1rem; }
/* Sunucu verisi: Defne'nin serif üslubundan ayrı, sistem fontu, küçük */
.changes {
  list-style: none;
  margin: 8px 0 4px;
  padding: 6px 0 0;
  border-top: 1px dashed var(--line);
  display: flex;
  flex-direction: column;
  gap: 2px;
  font: 500 13px/1.4 -apple-system, system-ui, sans-serif;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.change.created, .change.updated { color: var(--leaf); }
.change.cancelled { color: var(--warn); }
.rem-actions { display: flex; flex-direction: column; gap: 4px; margin: 8px 0 2px; }
.rem-note { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.rem-note.warn { color: var(--warn); }
.quick-row { display: flex; flex-wrap: wrap; gap: 8px; }
.quick, .secondary {
  flex-shrink: 0;
  min-height: 44px;
  padding: 0 14px;
  background: transparent;
  color: var(--leaf);
  border: 1px solid var(--leaf);
  font-size: 15px;
}
.rem-actions .error { overflow-wrap: anywhere; }
/* Sabahın anlık görüntüsü: saat ve metin ayrı sütunlarda */
.today {
  list-style: none;
  margin: 8px 0 12px;
  padding: 8px 0 0;
  border-top: 1px dashed var(--line);
  display: flex;
  flex-direction: column;
  gap: 4px;
  font: 500 15px/1.4 -apple-system, system-ui, sans-serif;
}
.today li { display: grid; grid-template-columns: 3.4rem minmax(0, 1fr); gap: 10px; }
.today-time { color: var(--muted); font-variant-numeric: tabular-nums; }
.today-title { overflow-wrap: anywhere; }
.from-you, .main, .turn p {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.thinking { color: var(--muted); font-style: italic; font-size: 15px; margin: 6px 0; }
.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
}
.card-foot time { font-size: 13px; color: var(--muted); }
.reply-btn { margin-right: -10px; padding: 0 10px; font-weight: 600; font-size: 15px; }

.thread {
  margin: 4px 0 6px 6px;
  padding-left: 12px;
  border-left: 2px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.turn { font-size: 15px; line-height: 1.45; }
.turn p { margin-top: 1px; }
.turn.defne p { color: var(--ink); }
.turn.me p { color: var(--muted); }
.turn time { font-size: 12px; color: var(--muted); margin-left: 6px; }

.empty { margin: 40px 8px; text-align: center; color: var(--muted); font: italic 1.1rem/1.4 var(--serif); }

.fab {
  position: absolute;
  right: 16px;
  bottom: calc(env(safe-area-inset-bottom) + 16px);
  min-height: 48px;
  padding: 0 1.3rem;
  border-radius: 24px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}

.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  padding: 8px 14px calc(env(safe-area-inset-bottom) + 10px);
  background: var(--card);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.14);
  animation: rise 0.22s ease-out;
}
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
.sheet-head { display: flex; align-items: center; gap: 8px; }
.quote {
  flex: 1;
  min-width: 0;
  padding-left: 10px;
  border-left: 3px solid var(--leaf);
  color: var(--muted);
  font: italic 0.95rem/1.35 var(--serif);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sheet-row { display: flex; align-items: flex-end; gap: 8px; }
#input {
  flex: 1;
  min-width: 0;
  resize: none;
  max-height: calc(5 * 1.4em + 1.3rem + 2px);
  overflow-y: auto;
  line-height: 1.4;
}
.sheet .error { margin-top: 4px; }

#settings-sheet { max-height: calc(100% - 16px); overflow-y: auto; overscroll-behavior: contain; }
#settings-sheet:focus { outline: none; }
#settings-sheet > * + * { margin-top: 8px; }
#settings-sheet > :empty { margin-top: 0; }
.sheet-title { flex: 1; min-width: 0; font: 700 1.1rem/1.3 var(--serif); overflow-wrap: anywhere; }
.field, .switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
}
.field label, .switch-row span { min-width: 0; font-size: 16px; overflow-wrap: anywhere; }
.field input { width: 9rem; flex-shrink: 0; }
.switch-row { cursor: pointer; }
.switch-row input {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  flex-shrink: 0;
  width: 52px;
  min-height: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 16px;
  background: var(--line);
  cursor: pointer;
  transition: background 0.15s;
}
.switch-row input::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--card);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s;
}
.switch-row input:checked { background: var(--leaf); }
.switch-row input:checked::before { transform: translateX(20px); background: var(--bg); }
.switch-row input:focus-visible { outline: 2px solid var(--warn); outline-offset: 2px; }
.sheet-actions { display: flex; flex-wrap: wrap; gap: 8px; }

@media (prefers-reduced-motion: reduce) {
  .sheet, .card.flash { animation: none; }
  .switch-row input, .switch-row input::before { transition: none; }
  .card.flash { box-shadow: 0 0 0 3px var(--leaf); }
}
