/* Karakterim (web/js/character.js): ortada bir kart; solda alacakaranlıkta dönen karakter, sağda sekmeli seçenekler
   (küçük resimli kutular, renk yuvarlakları, anahtarlar). Telefonda alt alta. */

.ch {
  position: fixed; inset: 0; z-index: 120; display: grid; place-items: center; padding: 20px;
  background: rgb(0 0 0 / 0.55); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  animation: ch-in 0.18s ease-out;
}
.ch[hidden] { display: none; }
@keyframes ch-in { from { opacity: 0; } }
.ch-card {
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto; width: min(1000px, 100%); height: min(700px, 100%);
  overflow: hidden; border-radius: 16px; background: var(--panel); border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgb(0 0 0 / 0.45); animation: ch-pop 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.15);
}
@keyframes ch-pop { from { transform: scale(0.96) translateY(8px); opacity: 0; } }

.ch-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px 12px 20px; border-bottom: 1px solid var(--line); }
.ch-title { flex: 1; display: grid; gap: 2px; min-width: 0; }
.ch-title b { font-size: 16px; font-weight: 800; }
.ch-title small { color: var(--muted); font-size: 12px; }
.ch-x { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; color: var(--muted); font-size: 15px; }
.ch-x:hover { background: var(--raise); color: var(--fg); }

.ch-body { display: grid; grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr); min-height: 0; }

/* Sahne: alacakaranlık gökyüzü, ufukta sıcak bir ışık */
.ch-stage {
  position: relative; min-height: 0; overflow: hidden; touch-action: none;
  background:
    radial-gradient(70% 45% at 50% 88%, rgb(255 170 100 / 0.35), transparent 70%),
    linear-gradient(180deg, #1c2550 0%, #4a4a86 55%, #c98a7c 100%);
}
.ch-canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; }
.ch-stage.dragging .ch-canvas { cursor: grabbing; }
.ch-stage-tools { position: absolute; top: 12px; left: 12px; display: flex; gap: 6px; }
.ch-tool {
  height: 30px; padding: 0 11px; border-radius: 999px; color: #fff; font-size: 12px; font-weight: 600;
  background: rgb(0 0 0 / 0.28); border: 1px solid rgb(255 255 255 / 0.18); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.ch-tool:hover:not(:disabled) { background: rgb(0 0 0 / 0.42); }
.ch-tool:disabled { opacity: 0.45; cursor: default; }
.ch-hint {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); padding: 4px 10px; border-radius: 999px;
  color: rgb(255 255 255 / 0.8); background: rgb(0 0 0 / 0.25); font-size: 11px; transition: opacity 0.4s; pointer-events: none;
}
.ch-hint.seen { opacity: 0; }
.ch-loading { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; color: rgb(255 255 255 / 0.8); font-size: 13px; text-align: center; }
.ch-loading[hidden] { display: none; }

/* Seçenekler */
.ch-panel { display: grid; grid-template-rows: auto minmax(0, 1fr); min-height: 0; border-left: 1px solid var(--line); }
.ch-tabs { display: flex; gap: 4px; padding: 10px 16px 0; border-bottom: 1px solid var(--line); }
.ch-tab {
  position: relative; padding: 8px 14px 11px; color: var(--muted); font-size: 13px; font-weight: 700;
}
.ch-tab:hover { color: var(--fg); }
.ch-tab[aria-selected="true"] { color: var(--fg); }
.ch-tab[aria-selected="true"]::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--accent); }
.ch-sections { min-height: 0; overflow-y: auto; padding: 6px 18px 18px; }
.ch-pane[hidden] { display: none; }
.ch-row { display: grid; gap: 8px; padding: 12px 0; border-bottom: 1px solid color-mix(in srgb, var(--line) 60%, transparent); }
.ch-row:last-child { border-bottom: 0; }
.ch-row[hidden] { display: none; }
.ch-label { color: var(--faint); font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }

.ch-opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.ch-opt {
  display: grid; justify-items: center; gap: 4px; padding: 6px 4px 7px; border-radius: 12px;
  background: var(--raise); border: 1px solid var(--line); color: var(--muted); font-size: 12px;
  transition: border-color 0.15s, transform 0.15s, background 0.15s;
}
.ch-opt img {
  width: 100%; max-width: 88px; aspect-ratio: 1; border-radius: 9px; object-fit: cover;
  background: linear-gradient(180deg, #2a3466, #6b5f93 70%, #b88a86);
}
.ch-opt img:not([src]) { visibility: hidden; }
.ch-opt:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); transform: translateY(-1px); }
.ch-opt[aria-pressed="true"] { color: var(--fg); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--raise)); box-shadow: 0 0 0 1px var(--accent); }

.ch-swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.ch-sw {
  position: relative; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--c); box-shadow: inset 0 0 0 1px rgb(0 0 0 / 0.18); transition: transform 0.12s;
}
.ch-sw:hover { transform: scale(1.1); }
.ch-sw[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--accent); }
.ch-sw.auto span { color: #fff; font-size: 9px; font-weight: 800; text-shadow: 0 1px 2px rgb(0 0 0 / 0.6); }

.ch-flags { display: flex; flex-wrap: wrap; gap: 10px 22px; }
.ch-flag { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; cursor: pointer; }

/* Alt çubuk: kaydedilmemiş değişiklik varken renklenir; Esc'te sallanır */
.ch-foot {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px 12px 20px; border-top: 1px solid var(--line);
  transition: background 0.2s;
}
.ch-foot.dirty { background: color-mix(in srgb, var(--accent) 8%, var(--panel)); }
.ch-msg { flex: 1; min-width: 0; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-foot.dirty .ch-msg { color: var(--fg); }
.ch-msg.err { color: var(--err); }
.ch-foot.shake { animation: ch-shake 0.42s; }
@keyframes ch-shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.ch-cancel { height: 34px; padding: 0 14px; border-radius: 8px; color: var(--muted); font-size: 13px; }
.ch-cancel:hover { background: var(--raise); color: var(--fg); }
.ch-save {
  min-width: 96px; height: 34px; padding: 0 16px; border-radius: 8px; font-size: 13px; font-weight: 800;
  background: var(--accent); color: var(--accent-fg);
}
.ch-save:disabled { opacity: 0.45; cursor: default; }

/* Ayarlar → Hesabım'daki giriş */
.st-char { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px; }
.st-char img { width: 44px; height: 44px; }
.st-char p { color: var(--muted); font-size: 13px; line-height: 1.5; }

@media (max-width: 720px) {
  .ch { padding: 0; }
  .ch-card { width: 100%; height: 100%; border-radius: 0; border: 0; }
  .ch-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: 38vh minmax(0, 1fr); }
  .ch-panel { border-left: 0; border-top: 1px solid var(--line); }
  .ch-opts { grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }
  .st-char { grid-template-columns: auto minmax(0, 1fr); }
  .st-char .st-btn { grid-column: 1 / -1; }
}
.ch-card:focus { outline: none; }
