:root {
  --bg: #f7f3ec; --card: #fffdf8; --ink: #2b2724; --muted: #8a8178; --line: #e6ddd0;
  --accent: #b5523b; --accent2: #3e6b70; --ok: #4f7d4a; --bad: #b5523b; --me: #e9f0ef;
  --side: #efe8dc;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink);
  font: 17px/1.7 "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Noto Sans JP", -apple-system, "Segoe UI", sans-serif; }
button, select, textarea, input { font: inherit; color: inherit; }

#app { display: grid; grid-template-columns: 290px 1fr; height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }

/* ---------- sol sütun ---------- */
#side { background: var(--side); padding: 14px; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.avatar-wrap { width: 100%; aspect-ratio: 4 / 5; max-height: 46dvh; }
#avatar { width: 100%; height: 100%; display: block; }
.char-name { text-align: center; font-weight: 700; font-size: 19px; }
.credit { text-align: center; color: var(--muted); font-size: 12px; }
#nav { display: flex; flex-direction: column; gap: 8px; }
#nav button { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); text-align: left; cursor: pointer; }
#nav button.on { border-color: var(--accent2); background: #e3eceb; }

/* ---------- sağ taraf ---------- */
#right { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
#top { display: flex; align-items: center; gap: 12px; padding: 10px 18px; border-bottom: 1px solid var(--line); }
#top h1 { flex: 1; font-size: 19px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tr-toggle { display: flex; align-items: center; gap: 6px; font-size: 15px; white-space: nowrap; }
.tr-toggle input { width: 20px; height: 20px; }
#sel-furi { border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; background: var(--card); font-size: 15px; }
#main { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
#content { padding: 16px 20px 30px; max-width: 900px; }

#composer { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); background: var(--bg); }
#input { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px;
  background: var(--card); font-size: 18px; min-height: 52px; max-height: 160px; }
#composer button { border: 0; border-radius: 14px; padding: 0 18px; cursor: pointer; font-size: 17px; }
#btn-send { background: var(--accent2); color: white; }
#btn-mic { background: var(--card); border: 1px solid var(--line) !important; font-size: 22px; min-width: 58px; }
#btn-mic.rec { background: var(--accent); color: white; animation: pulse 1.2s infinite; }
#composer button:disabled { opacity: .4; }
@keyframes pulse { 50% { opacity: .65; } }

/* ---------- içerik ---------- */
h2 { font-size: 22px; margin: 6px 0 2px; } h3 { font-size: 18px; margin: 18px 0 8px; }
.muted { color: var(--muted); font-size: 15px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 18px; margin: 12px 0; }
.card.warn { border-color: #e3b3a5; }
.ja { font-size: 21px; line-height: 2.3; }
ruby rt { font-size: .5em; color: #7b6f66; }
.tr { display: none; color: var(--muted); font-size: 15px; line-height: 1.5; margin-top: 2px; }
body.show-tr .tr, .tr.open { display: block; }
.btn { display: inline-block; border: 0; color: #fff; background: var(--accent2); padding: 9px 18px;
  border-radius: 999px; font-size: 16px; margin: 6px 8px 4px 0; cursor: pointer; text-decoration: none; }
.btn.alt { background: transparent; color: var(--accent2); border: 1px solid var(--accent2); }
.btn.warm { background: var(--accent); }
.icon { border: 0; background: none; font-size: 20px; padding: 2px 6px; cursor: pointer; opacity: .8; vertical-align: middle; }
.toggle { border: 0; background: none; color: var(--accent2); font-size: 13px; padding: 2px 6px; cursor: pointer; vertical-align: middle; }
.msg { display: flex; margin: 10px 0; }
.msg .b { max-width: 86%; padding: 10px 14px; border-radius: 16px; }
.msg.me { justify-content: flex-end; } .msg.me .b { background: var(--me); border-bottom-right-radius: 4px; }
.msg.ai .b { background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.fix { margin-top: 8px; padding: 8px 10px; border-left: 3px solid var(--accent); background: #fbefe9; border-radius: 6px; font-size: 15px; line-height: 1.6; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; background: #efe7da; font-size: 14px; margin: 2px; }
.thinking { color: var(--muted); font-style: italic; }
table { border-collapse: collapse; width: 100%; } td, th { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 13px; color: var(--muted); }

/* ayarlar */
.form label { display: block; margin: 12px 0 4px; font-weight: 600; font-size: 15px; }
.form input[type=text], .form input[type=password], .form select, .form textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; background: white; font-size: 16px; }
.form textarea { min-height: 80px; }
.form .row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.form .hint { font-size: 13px; color: var(--muted); }

#toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #2b2724; color: white; padding: 8px 16px; border-radius: 999px; font-size: 15px;
  opacity: 0; pointer-events: none; transition: opacity .25s; max-width: 90vw; text-align: center; }
#toast.show { opacity: .92; }

/* ---------- dikey iPad / dar ekran ---------- */
@media (max-width: 900px), (orientation: portrait) {
  #app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  #side { flex-direction: row; align-items: stretch; padding: 10px 12px; }
  .avatar-wrap { width: auto; height: 190px; aspect-ratio: 4 / 5; max-height: none; flex: none; }
  .side-info { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
  .char-name { text-align: left; }
  #nav { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  #nav button { padding: 8px 12px; }
}
@media (max-width: 560px) {
  #nav button span { display: none; }
  #nav { grid-template-columns: repeat(4, 1fr); }
  #nav button { justify-content: center; font-size: 22px; }
  .avatar-wrap { height: 130px; }
}
