/* =========================================================
   Çok cihaz uyumu: telefon (dik/yatay), tablet, masaüstü, dokunmatik.
   index.html'de EN SON yüklenir; stil.css, stil-gorsel.css ve stil-bolme.css ile örtüşen
   kurallarda son sözü bu dosya söyler. Yeni kural eklerken şu üç aralığı koru:
     A) ≤ 860px ve yükseklik > 540px  → belge listesi üstte, defter ALT ÇEKMECE (cihaz.js tutamacı)
     B) 541–1100px yatay (≤ 540px yüksek ya da 861–1100px geniş) → liste + belge, defter YAN ÇEKMECE
     C) > 1100px → üç sütun (stil.css)
   ========================================================= */

/* ---------- genel dokunmatik ayarları ---------- */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
#sahne { touch-action: none; }
button, summary, select, input, textarea, label, .doc-btn, .tab, .sun-btn, .itiraz-btn { touch-action: manipulation; }
button { -webkit-tap-highlight-color: rgba(232, 195, 111, .25); }
.viewer, .nb-page, .index, .modal-card, .ogr-katman, .pano-katman, .bolme-pane { overscroll-behavior: contain; }
.modal-card, .ogr-katman, .case { -webkit-overflow-scrolling: touch; }

/* dokunma hedefleri ≥ 44px */
@media (pointer: coarse) {
  .hud-btn, .bar-back, .bar-report, .bar-ipucu, .m-btn, .sun-btn, .tab, .gez-btn, .sorgu-btn, .bil-btn,
  .doc-btn, .isaret button, .iz-pill, .kirp-yan, .bolme-sekmeler button, .gk-baglanti, .hk-pano { min-height: 44px; }
  .gez-btn { min-width: 44px; }
  .tab { padding-top: 10px; padding-bottom: 9px; }
  .doc-btn { padding-top: 9px; padding-bottom: 9px; }
  .itiraz-btn { display: inline-block; margin-top: 6px; padding: 9px 12px; font-size: 12.5px; }
  .cark button { height: 44px; width: 52px; }
  .cark output { height: 58px; }
  .isaret button { padding-left: 14px; padding-right: 14px; }
  .modal-card .m-actions .m-btn { min-width: 44px; }
  .kirp button, .kirp .sil, [data-act="kirpsil"] { min-width: 44px; min-height: 44px; }
  input[type="checkbox"], input[type="radio"] { min-width: 22px; min-height: 22px; }
}

/* ---------- giriş ekranı: dik telefon ---------- */
@media (max-width: 640px) {
  .giris-kutu { width: min(344px, calc(100vw - 28px)); bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
  .ogretici-btn { top: calc(12px + env(safe-area-inset-top, 0px)); bottom: auto; left: calc(12px + env(safe-area-inset-left, 0px)); padding: 6px 12px; }
  .sound { top: calc(12px + env(safe-area-inset-top, 0px)); right: calc(12px + env(safe-area-inset-right, 0px)); }
  .baslik-kart { top: 11vh; padding: 14px 14px 18px; }
  .skip { bottom: calc(18px + env(safe-area-inset-bottom, 0px)); }
}
/* yatay telefon: kutu sağda, başlık solda */
@media (orientation: landscape) and (max-height: 540px) {
  .baslik-kart { left: calc(18px + env(safe-area-inset-left, 0px)); top: 8px; translate: none; width: min(44vw, 420px); text-align: left; padding: 8px 10px; }
  .baslik-kart h1 { font-size: clamp(24px, 5.4vw, 38px); }
  .bk-alt, .bk-ust { display: none; }
  .giris-kutu { left: auto; right: calc(14px + env(safe-area-inset-right, 0px)); translate: none; bottom: 8px; width: min(310px, 44vw); max-height: calc(100dvh - 16px); }
  .giris-kutu .enter { min-height: 54px; margin-top: 8px; }
  .gk-sekmeler button { min-height: 40px; }
  .giris-kutu input { min-height: 40px; }
  .gk-form { gap: 6px; }
  .ogretici-btn { top: auto; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
  .hud-name { display: none; }
  .hedef-kart { bottom: 8px; width: min(250px, 38vw); font-size: 11.5px; }
}

/* =========================================================
   DAVA EKRANI
   ========================================================= */

/* tutamaç düğmesi (cihaz.js ekler); geniş ekranda gizli */
.cz-tutamac { display: none; }

/* ----- A) dar ekran: üst üste, defter alt çekmece ----- */
@media (max-width: 860px) {
  .case { padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)); }
  .bar { grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 8px 10px; padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 8px; }
  .bar-title h1 { font-size: 16px; line-height: 1.2; white-space: normal; }
  .bar-title small { font-size: 11px; }
  .bar-right { flex-wrap: wrap; justify-content: flex-start; gap: 8px 10px; }
  .bar-back, .bar-ipucu, .bar-report { padding: 8px 12px; font-size: 13px; }
  .bar-report { flex: 1 1 130px; min-width: 0; white-space: normal; text-align: center; }
  .gozetim-damga { font-size: 11px; }

  .cols { padding: 8px 10px 0; }
  .index { padding: 8px 10px 4px; margin-bottom: 8px; }
  .index h2 { display: none; }
  .ilerleme { display: flex; flex-wrap: wrap; gap: 2px 12px; margin: 0 0 6px; }
  .ilerleme span { display: inline-flex; gap: 4px; align-items: baseline; padding: 0; background: none; text-align: left; font-size: 11.5px; }
  .ilerleme .il-alt { display: none; }
  .ilerleme .iz-pill { flex: 1 1 100%; margin: 2px 0 0; }
  .index nav { gap: 6px; padding-bottom: 8px; scroll-snap-type: x proximity; }
  .doc-btn { scroll-snap-align: start; min-height: 36px; max-width: 46vw; padding-top: 4px; padding-bottom: 4px; font-size: 12.5px; }
  .doc-btn .ad { white-space: normal; max-width: 34vw; line-height: 1.2; }
  .view-bar { gap: 8px; padding: 4px 0; margin-bottom: 10px; }
  .view-bar .sun-btn, .bolme-grup .sun-btn { min-height: 40px; }
  .paper { padding: 28px 18px 34px; }
  .viewer { padding-bottom: 12px; }

  /* defter: alt çekmece */
  .notebook {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; margin: 0;
    display: flex; flex-direction: column; gap: 0;
    height: calc(48px + env(safe-area-inset-bottom, 0px)); overflow: hidden;
    padding: 0 8px env(safe-area-inset-bottom, 0px);
    border-radius: 12px 12px 0 0;
    background: linear-gradient(180deg, #3e2a1c, #2c1d14);
    box-shadow: 0 -10px 30px rgba(0, 0, 0, .55), inset 0 2px 0 rgba(255, 255, 255, .08);
    transition: height .28s cubic-bezier(.2, .8, .3, 1);
  }
  .notebook.cz-acik { height: min(76dvh, 600px); }
  .cz-tutamac {
    display: flex; align-items: center; justify-content: center; gap: 10px; flex: none; width: 100%; height: 48px; cursor: pointer;
    background: none; border: 0; color: #efe6d2; font-family: var(--type); font-weight: 700; font-size: 14px;
  }
  .cz-tutamac::before { content: ""; width: 38px; height: 4px; border-radius: 2px; background: rgba(239, 230, 210, .45); }
  .cz-ad { white-space: nowrap; }
  .cz-nokta { width: 9px; height: 9px; border-radius: 50%; background: #e3c27a; animation: cz-nabiz 1.4s ease-in-out infinite; }
  .cz-tutamac .cz-ok { display: inline-block; transition: transform .25s; }
  .notebook.cz-acik .cz-ok { transform: rotate(180deg); }
  .notebook .tabs { flex: none; padding-left: 2px; overflow-x: auto; }
  .notebook .tab { flex: 1 0 auto; }
  .nb-page { flex: 1 1 auto; max-height: none; padding: 14px 14px 24px; }
}
@keyframes cz-nabiz { 50% { opacity: .35; } }

@media (max-width: 560px) {
  .ilerleme { gap: 2px 10px; }
  .ilerleme span { font-size: 11px; }
  .index { margin-bottom: 4px; }
  .paper { padding-top: 18px; }
  .itibar > span:first-child { display: none; }
  .bar-back, .bar-ipucu, .bar-report { padding: 8px 10px; font-size: 12.5px; }
  .bar-right { gap: 8px; }
}

/* ----- B) yatay telefon / küçük laptop: liste + belge, defter yan çekmece ----- */
@media (min-width: 541px) and (max-width: 1100px) and ((min-width: 861px) or (max-height: 540px)) {
  .case { display: grid; grid-template-rows: auto minmax(0, 1fr); overflow: hidden; padding-bottom: 0; }
  .bar { grid-template-columns: auto minmax(0, 1fr) auto; padding: 6px 14px; gap: 8px 12px; }
  .bar-title { text-align: center; }
  .bar-title small { display: none; }
  .bar-title h1 { font-size: 16px; }
  .bar-right { grid-column: auto; justify-self: end; flex-wrap: nowrap; gap: 8px; }
  .bar-back, .bar-ipucu, .bar-report { padding: 7px 12px; font-size: 13px; }
  .cols, .cols.bolme-acik { display: grid; grid-template-columns: 176px minmax(0, 1fr); gap: 12px; padding: 8px 10px 0; min-height: 0; }
  .index { display: block; max-height: 100%; margin: 0; padding: 10px 8px 12px; overflow-y: auto; }
  .index nav { display: block; overflow: visible; padding: 0; }
  .index h2 { display: block; font-size: 13px; margin-bottom: 6px; }
  .index h3 { display: block; }
  .doc-btn { width: 100%; max-width: none; background: none; min-height: 40px; }
  .doc-btn .ad { white-space: normal; max-width: none; }
  .ilerleme { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; }
  .ilerleme span { display: grid; padding: 4px 2px; background: rgba(255, 255, 255, .28); text-align: center; font-size: 10.5px; }
  .ilerleme .il-alt { display: none; }
  .viewer { overflow-y: auto; padding: 0 4px 80px; }
  .paper::before { display: block; }

  .notebook {
    position: fixed; top: 0; right: 0; bottom: 0; left: auto; z-index: 25; width: min(88vw, 400px); margin: 0; height: auto;
    background: linear-gradient(90deg, #2c1d14, #3e2a1c 8%, #34241a); box-shadow: -14px 0 36px rgba(0, 0, 0, .55), inset 3px 0 0 #1c120c;
    display: flex; flex-direction: column; padding: 10px 10px 10px 14px; overflow: visible;
    border-radius: 10px 0 0 10px; transform: translateX(100%); transition: transform .28s cubic-bezier(.2, .8, .3, 1);
  }
  .notebook.cz-acik { transform: none; }
  .cz-tutamac {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
    position: absolute; left: -48px; top: 38%; width: 48px; height: 112px; cursor: pointer;
    background: linear-gradient(90deg, #3e2a1c, #2c1d14); border: 0; border-radius: 10px 0 0 10px;
    box-shadow: -6px 4px 16px rgba(0, 0, 0, .45); color: #efe6d2; font-family: var(--type); font-weight: 700; font-size: 13px;
  }
  .cz-ad { writing-mode: vertical-rl; transform: rotate(180deg); letter-spacing: .06em; }
  .cz-tutamac .cz-ok { display: none; }
  .cz-nokta { width: 9px; height: 9px; border-radius: 50%; background: #e3c27a; animation: cz-nabiz 1.4s ease-in-out infinite; }
  .nb-page { flex: 1 1 auto; min-height: 0; max-height: none; }
  .notebook .tabs { flex: none; }
}
.cz-nokta[hidden] { display: none; }

/* yatay çok kısa ekran: boşluk kıt */
@media (orientation: landscape) and (max-height: 430px) {
  .bar { padding-top: 4px; padding-bottom: 4px; }
  .bar-title h1 { font-size: 14px; }
  .itibar span:first-child { display: none; }
  .paper { padding: 22px 16px 26px; font-size: 14px; }
  .view-bar { margin-bottom: 6px; }
}

/* ----- geniş ekranlarda (C) hiçbir şey değişmez ----- */

/* ---------- açılır pencereler: telefon ---------- */
@media (max-width: 560px) {
  .modal { padding: 0; align-items: end; }
  .modal-card { width: 100%; max-height: 94dvh; padding: 22px 16px calc(22px + env(safe-area-inset-bottom, 0px)); border-radius: 10px 10px 0 0; }
  .modal-card.sorgu-oda { height: 100dvh; max-height: 100dvh; border-radius: 0; }
  .m-actions { gap: 8px; }
  .m-actions .m-btn { flex: 1 1 auto; text-align: center; }
  .pano-katman { padding: 8px 8px calc(16px + env(safe-area-inset-bottom, 0px)); }
  .pano-bas { padding: 10px 12px; }
  .pano-kartlar { grid-template-columns: minmax(0, 1fr); }
  .tag-tip { max-width: calc(100vw - 16px); }
}
@media (max-height: 520px) and (orientation: landscape) {
  .modal-card { max-height: 98dvh; padding-top: 18px; padding-bottom: 14px; }
}

/* ---------- arşiv odası: hedef kartı ---------- */
@media (max-width: 640px) {
  .hedef-kart { left: 10px; right: 10px; width: auto; bottom: calc(66px + env(safe-area-inset-bottom, 0px)); }
}

/* ---------- yatay telefon ipucu ---------- */
.cz-ipucu {
  position: fixed; left: 50%; bottom: calc(66px + env(safe-area-inset-bottom, 0px)); translate: -50% 0; z-index: 60;
  display: flex; align-items: center; gap: 10px; width: min(360px, calc(100vw - 24px)); padding: 10px 12px;
  background: rgba(20, 18, 16, .95); color: #efe6d2; border: 1px solid rgba(233, 205, 140, .5); border-radius: 8px;
  font-family: var(--type); font-size: 13px; line-height: 1.45; box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
  animation: belir .5s ease both;
}
.cz-ipucu button { flex: none; min-width: 44px; min-height: 44px; background: none; border: 1px solid rgba(233, 228, 214, .35); border-radius: 4px; color: inherit; cursor: pointer; font-family: var(--type); }
.cz-ipucu[hidden] { display: none; }
.cz-ipucu .cz-donus { display: inline-block; flex: none; font-size: 22px; }

@media (prefers-reduced-motion: reduce) {
  .notebook, .cz-tutamac .cz-ok { transition: none; }
  .cz-nokta, .cz-ipucu { animation: none; }
}
