:root {
  --bg: #f6efe6;
  --bg-2: #fffaf3;
  --ink: #2b2118;
  --ink-2: #6f5f52;
  --ink-3: #a4958a;
  --line: #e6dbcd;
  --accent: #b5472f;
  --accent-soft: #f3d9d0;
  --seen: #4f7a5a;
  --box: #e9dccb;
  --box-2: #d9c7b0;
  --shadow: 0 10px 30px rgba(60, 40, 20, .10);
  --radius: 18px;
  --serif: "Fraunces", "Iowan Old Style", Georgia, serif;
  --sans: "Inter", -apple-system, system-ui, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1814;
    --bg-2: #262019;
    --ink: #f1e8dc;
    --ink-2: #bcae9f;
    --ink-3: #7e7064;
    --line: #3a3128;
    --accent: #e07a5f;
    --accent-soft: #4a2c23;
    --seen: #8cc39a;
    --box: #342b22;
    --box-2: #45382b;
    --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }

/* ---------- Kabuk ---------- */
.shell { max-width: 640px; margin: 0 auto; padding: 0 16px 110px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(14px + env(safe-area-inset-top)) 0 12px;
  position: sticky; top: 0; z-index: 5;
  background: linear-gradient(var(--bg) 80%, transparent);
}
.brand {
  font-family: var(--serif); font-weight: 500; font-size: 30px; letter-spacing: -.02em;
  text-decoration: none; line-height: 1;
}
.brand i { color: var(--accent); font-style: normal; }
.topbar .sub { flex: 1; text-align: center; font-size: 13px; color: var(--ink-3); font-family: var(--serif); font-style: italic; }
.user-btn {
  border: 1px solid var(--line); background: var(--bg-2); border-radius: 999px;
  padding: 6px 12px; font-size: 13px; display: flex; gap: 6px; align-items: center; white-space: nowrap;
}

/* ---------- Giriş ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 360px; background: var(--bg-2); border-radius: 24px;
  box-shadow: var(--shadow); padding: 36px 28px; text-align: center;
}
.login-card .brand { font-size: 56px; display: block; margin-bottom: 4px; }
.login-card p { color: var(--ink-2); margin: 0 0 26px; font-family: var(--serif); font-style: italic; }
.login-card input {
  width: 100%; padding: 13px 14px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg); margin-bottom: 10px; outline: none;
}
.login-card input:focus { border-color: var(--accent); }
.err { color: var(--accent); font-size: 14px; min-height: 20px; margin: 4px 0 8px; }

/* ---------- Düğmeler ---------- */
.btn { border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 600; background: var(--ink); color: var(--bg); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { background: transparent; color: var(--ink-2); }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--bg-2); display: inline-grid; place-items: center; font-size: 18px;
}
.icon-btn.sm { width: 32px; height: 32px; font-size: 15px; }

/* ---------- Yazma kutusu (sahibi) ---------- */
.composer {
  background: var(--bg-2); border-radius: var(--radius); padding: 14px 14px 10px; margin-bottom: 22px;
  box-shadow: var(--shadow); border: 1px solid var(--line);
}
.composer textarea {
  width: 100%; border: 0; background: transparent; resize: none; outline: none;
  font-size: 18px; line-height: 1.5; min-height: 84px; font-family: var(--serif);
}
.composer textarea::placeholder { color: var(--ink-3); font-style: italic; }
.composer-bar { display: flex; align-items: center; gap: 8px; margin-top: 8px; border-top: 1px solid var(--line); padding-top: 10px; }
.composer-bar .grow { flex: 1; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg); font-size: 13px; font-weight: 500; cursor: pointer; color: var(--ink-2);
}
.chip input[type=file] { display: none; }
.chip input[type=date], .chip input[type=time] {
  border: 0; background: transparent; padding: 0; font-size: 13px; font-weight: 500; color: var(--ink); outline: none;
  -webkit-appearance: none; appearance: none; min-width: 112px;
}
.chip input[type=time] { min-width: 56px; }
.chip input[type=date]::-webkit-calendar-picker-indicator, .chip input[type=time]::-webkit-calendar-picker-indicator { opacity: 0; position: absolute; }
.note-head .date .clock { font-family: var(--sans); font-weight: 600; font-size: 13px; color: var(--accent); margin-left: 4px; }
.field.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field.row2 > div { display: flex; flex-direction: column; gap: 4px; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px; margin-top: 6px; }
.thumbs:empty { display: none; }
.thumbs .t { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--bg); border: 1px solid var(--line); }
.thumbs .t img, .thumbs .t video { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumbs .t .x {
  position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; border: 0;
  background: rgba(0,0,0,.6); color: #fff; font-size: 14px; line-height: 1; display: grid; place-items: center;
}
.progress { height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; margin-top: 8px; display: none; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s; }

/* ---------- Gönderi kartı ---------- */
.note {
  background: var(--bg-2); border-radius: var(--radius); padding: 14px 16px 12px; margin-bottom: 12px;
  box-shadow: 0 1px 0 var(--line);
}
.note-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.note-head .date { font-family: var(--serif); font-size: 17px; font-weight: 500; }
.note-head .date small { color: var(--ink-3); font-family: var(--sans); font-size: 12px; margin-left: 6px; }
.note-head .acts { display: flex; gap: 6px; }
.note h2 { font-family: var(--serif); font-weight: 500; font-size: 21px; margin: 0 0 6px; }
.note .body, .r-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 16.5px; line-height: 1.6; }
.note .body:empty { display: none; }
.media { display: grid; gap: 6px; margin-top: 12px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.media.one { grid-template-columns: 1fr; }
.media .m { border-radius: 12px; overflow: hidden; background: var(--bg); position: relative; aspect-ratio: 1; border: 0; padding: 0; display: block; width: 100%; }
.media.one .m { aspect-ratio: auto; }
.media .m img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media.one .m img { max-height: 70vh; object-fit: contain; }
.media .m video { width: 100%; height: 100%; object-fit: cover; display: block; background: #000; }
.media.one .m video { max-height: 70vh; object-fit: contain; }
.note-foot { margin-top: 10px; font-size: 12px; color: var(--ink-3); }
.note-foot .seen { color: var(--seen); font-weight: 500; }
.empty { text-align: center; color: var(--ink-3); padding: 50px 20px; font-family: var(--serif); font-style: italic; font-size: 18px; }
.empty .glyph { font-size: 40px; display: block; margin-bottom: 10px; font-style: normal; opacity: .5; }

/* ---------- Kutular (görüntüleyici) ---------- */
.hint { text-align: center; color: var(--ink-3); font-family: var(--serif); font-style: italic; margin: 4px 0 18px; font-size: 15px; }
.boxes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (min-width: 480px) { .boxes { grid-template-columns: repeat(4, 1fr); } }
.box {
  aspect-ratio: 1; border-radius: 16px; border: 0; padding: 0; position: relative; overflow: hidden;
  background: linear-gradient(145deg, var(--box), var(--box-2));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 2px 0 rgba(0,0,0,.06);
  display: grid; place-items: center; transition: transform .12s ease;
  animation: pop .4s ease both; animation-delay: calc(var(--i) * 18ms);
}
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
.box:active { transform: scale(.94); }
.box .lock { font-size: 26px; opacity: .55; filter: grayscale(.3); }
.box .chest { width: 82%; height: 82%; object-fit: contain; filter: drop-shadow(0 6px 8px rgba(60, 35, 10, .28)); pointer-events: none; }
.box.opening .chest { animation: chest-glow .65s ease; }
@keyframes chest-glow { 50% { filter: drop-shadow(0 0 14px rgba(255, 200, 90, .9)) brightness(1.15); } }
.box.opening { animation: shake .65s ease; }
@keyframes shake {
  0%, 100% { transform: rotate(0); }
  15% { transform: rotate(-6deg) scale(1.05); }
  30% { transform: rotate(6deg) scale(1.05); }
  45% { transform: rotate(-4deg) scale(1.08); }
  60% { transform: rotate(4deg) scale(1.08); }
  80% { transform: rotate(0) scale(1.12); }
}
.box.open { background: var(--bg-2); border: 1px solid var(--line); box-shadow: none; }
.box.open img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.box.open .txt {
  padding: 10px; font-family: var(--serif); font-size: 12px; line-height: 1.35; color: var(--ink-2); text-align: left;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; align-self: start; width: 100%;
}
.box.open .lbl {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 4px 6px; font-size: 10.5px; font-weight: 600; text-align: center;
  background: linear-gradient(transparent, rgba(0,0,0,.55)); color: #fff; letter-spacing: .02em;
}
.box.open:not(:has(img)) .lbl { background: var(--bg); color: var(--ink-3); border-top: 1px solid var(--line); }

/* ---------- FAB ---------- */
.fab {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(22px + env(safe-area-inset-bottom)); z-index: 6;
  border: 0; border-radius: 999px; background: var(--accent); color: #fff; font-weight: 600;
  padding: 14px 22px; font-size: 15px; box-shadow: 0 10px 24px rgba(181, 71, 47, .4); white-space: nowrap;
}

/* ---------- Alt sayfa (editör / açılan kutu) ---------- */
#overlay:empty { display: none; }
#overlay { position: fixed; inset: 0; z-index: 20; background: rgba(20, 14, 10, .55); display: grid; place-items: end center; backdrop-filter: blur(3px); }
.sheet {
  width: 100%; max-width: 640px; max-height: 94dvh; overflow: auto; background: var(--bg);
  border-radius: 24px 24px 0 0; padding: 16px 18px calc(28px + env(safe-area-inset-bottom));
  animation: up .22s ease;
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sheet-head h3 { margin: 0; font-family: var(--serif); font-weight: 500; font-size: 22px; line-height: 1.1; }
.sheet-head h3 small { display: block; font-size: 12px; color: var(--ink-3); font-family: var(--sans); font-weight: 400; margin-top: 3px; }
.reveal.fresh { animation: reveal .5s cubic-bezier(.2,.8,.2,1); }
@keyframes reveal { from { transform: translateY(60px) scale(.96); opacity: 0; } }
.r-title { font-family: var(--serif); font-weight: 500; font-size: 22px; margin: 4px 0 8px; }
.r-body { font-size: 18px; font-family: var(--serif); line-height: 1.6; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 6px; }
.field input, .field textarea {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg-2); outline: none;
}
.field input:focus, .field textarea:focus { border-color: var(--accent); }
.field textarea { min-height: 140px; resize: vertical; line-height: 1.55; }
.field input[type=date] { -webkit-appearance: none; appearance: none; min-height: 46px; }
.pick { display: flex; align-items: center; gap: 10px; }
.pick label.btn { display: inline-block; text-transform: none; letter-spacing: 0; font-size: 15px; color: var(--bg); margin: 0; }
.pick input[type=file] { display: none; }
.pick span { font-size: 13px; color: var(--ink-3); }
.sheet .thumbs { margin-top: 10px; }
.sheet-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; align-items: center; }
.sheet-foot .danger { margin-right: auto; color: var(--accent); }

/* ---------- Lightbox ---------- */
.lightbox { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.94); display: grid; place-items: center; }
.lightbox img { max-width: 100vw; max-height: 100dvh; object-fit: contain; }
.lightbox .x { position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 14px; }
.lightbox .cnt { position: absolute; bottom: calc(14px + env(safe-area-inset-bottom)); left: 0; right: 0; text-align: center; color: #bbb; font-size: 13px; }
.lightbox .arr { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,.12); border-color: transparent; color: #fff; }
.lightbox .arr.l { left: 10px; } .lightbox .arr.r { right: 10px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px; z-index: 40;
  box-shadow: var(--shadow); animation: up .2s ease; white-space: nowrap;
}
.toast.err { background: var(--accent); color: #fff; }

@media (max-width: 420px) {
  .media { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
  .topbar .sub { font-size: 12px; }
}
