:root {
  --ink: #f3f0e9;
  --teal-950: #10282e;
  --panel-line: #c7cece;
  --panel-text: #26393d;
  --accent: #d99a4e;
  --accent-soft: #f1b56e;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html,
body {
  width: 100%;
  min-width: 320px;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--teal-950);
}

body {
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input { font: inherit; }

.text-icon {
  display: inline-block;
  font-size: 21px;
  line-height: 1;
}

.spinner {
  color: #e3b16e;
  font-size: 34px;
  line-height: 1;
  animation: spin 1s linear infinite;
}

button,
a { -webkit-tap-highlight-color: transparent; }

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent-soft);
  outline-offset: 2px;
}

.viewer-app {
  width: 100vw;
  height: 100dvh;
  min-height: 520px;
  position: relative;
  display: grid;
  grid-template-rows: 58px minmax(0, 1fr) 28px;
  overflow: hidden;
  background:
    radial-gradient(circle at 72% 18%, rgba(255, 255, 255, 0.065), transparent 30%),
    linear-gradient(145deg, #24474f 0%, #10282e 57%, #17383f 100%);
}

.viewer-app::before {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 160px;
  pointer-events: none;
  opacity: 0.34;
  background:
    linear-gradient(160deg, transparent 34%, rgba(255, 255, 255, 0.08) 35%, transparent 35.5%),
    linear-gradient(168deg, transparent 46%, rgba(255, 255, 255, 0.05) 46.3%, transparent 46.9%);
}

.topbar {
  position: relative;
  z-index: 30;
  display: grid;
  grid-template-columns: minmax(310px, 1fr) auto minmax(180px, 1fr);
  align-items: center;
  min-height: 58px;
  padding: 0 10px 0 8px;
  background: rgba(30, 62, 70, 0.94);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 6px 28px rgba(5, 15, 18, 0.14);
  backdrop-filter: blur(12px);
}

.topbar-left,
.topbar-actions,
.page-control,
.toolbar-group,
.panel-title,
.search-status,
.result-heading {
  display: flex;
  align-items: center;
}

.topbar-left { min-width: 0; gap: 10px; }

.document-title {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
  white-space: nowrap;
}

.document-title strong {
  color: #fff;
  font-size: 14px;
  letter-spacing: 0.13em;
}

.document-title span {
  max-width: 28vw;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.76);
  font-size: 13px;
  text-overflow: ellipsis;
}

.page-control {
  justify-content: center;
  gap: 9px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 13px;
  font-weight: 700;
}

.page-control input {
  width: 74px;
  height: 34px;
  padding: 0 8px;
  color: #1e3034;
  text-align: center;
  background: #f4f4f0;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 4px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.12);
}

.topbar-actions { justify-content: flex-end; gap: 8px; }

/* Belge seçici (görüntüleyicide birden fazla belge olduğunda) */
.doc-switch {
  display: inline-flex;
  flex: none;
  gap: 2px;
  margin-left: 6px;
  padding: 3px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
}

.doc-switch a {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 12px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  text-decoration: none;
  border-radius: 6px;
  transition: color 150ms ease, background 150ms ease;
}

.doc-switch a:hover { color: #fff; background: rgba(255, 255, 255, 0.1); }
.doc-switch a.is-active { color: #17343b; background: #f3f0e9; }
.doc-switch a:focus-visible { outline: 2px solid var(--accent-soft); outline-offset: 2px; }
.doc-short { display: none; }

.zoom-readout {
  color: rgba(255, 255, 255, 0.64);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.icon-button,
.fit-button {
  min-width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: rgba(255, 255, 255, 0.83);
  background: transparent;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  text-decoration: none;
  transition: color 150ms ease, background 150ms ease, transform 150ms ease;
}

.icon-button i {
  width: 1.15em;
  font-size: 17px;
  text-align: center;
}

.topbar .icon-button i {
  font-size: 19px;
}

.icon-button:hover,
.icon-button.is-active,
.fit-button:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.icon-button:active,
.fit-button:active { transform: translateY(1px); }

.icon-button:disabled { color: rgba(255, 255, 255, 0.25); cursor: default; }
.icon-button:disabled:hover { background: transparent; }

.viewer-body {
  min-height: 0;
  position: relative;
  z-index: 2;
  display: flex;
  overflow: hidden;
}

.side-panel {
  flex: 0 0 318px;
  width: 318px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  color: var(--panel-text);
  background: rgba(232, 235, 234, 0.98);
  box-shadow: 12px 0 36px rgba(2, 12, 15, 0.18);
}

.search-panel {
  flex-basis: 340px;
  width: 340px;
  box-shadow: -12px 0 36px rgba(2, 12, 15, 0.18);
}

.panel-heading {
  height: 55px;
  flex: 0 0 55px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 9px 0 17px;
  color: #fff;
  background: #516b72;
  border-bottom: 1px solid rgba(0, 0, 0, 0.14);
}

.panel-title { gap: 10px; font-size: 15px; font-weight: 700; }
.panel-title i { width: 20px; text-align: center; }

.panel-tabs {
  flex: 0 0 43px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--panel-line);
}

.panel-tabs button {
  position: relative;
  color: #657478;
  background: #dfe4e3;
  border: 0;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.panel-tabs button.is-active { color: #274a52; background: #f4f5f3; }

.panel-tabs button.is-active::after {
  content: "";
  position: absolute;
  right: 22px;
  bottom: 0;
  left: 22px;
  height: 3px;
  background: var(--accent);
}

.toc-list,
.thumbnail-list,
.search-results {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-color: #8f9c9e transparent;
  scrollbar-width: thin;
}

.toc-group { border-bottom: 1px solid var(--panel-line); }

.toc-row {
  display: flex;
  min-height: 48px;
  background: rgba(255, 255, 255, 0.16);
  transition: background 150ms ease;
}

.toc-row:hover,
.toc-row.is-active { background: #f7f8f6; }
.toc-row.is-active { box-shadow: inset 4px 0 var(--accent); }

.toc-main,
.toc-toggle,
.toc-children button,
.thumbnail,
.search-results button {
  color: inherit;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.toc-main {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 9px 10px 18px;
  text-align: left;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

.toc-main span { overflow: hidden; text-overflow: ellipsis; }

.toc-main small,
.toc-children small { color: #768589; font-size: 11px; font-weight: 700; }

.toc-toggle { width: 38px; color: #6f7e81; }
.toc-toggle i { font-size: 12px; }
.toc-children { padding: 3px 0 8px; background: #f4f5f3; }

.toc-children button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 17px 8px 35px;
  color: #46575a;
  text-align: left;
  font-size: 13px;
}

.toc-children button:hover,
.toc-children button.is-active { color: #17343b; background: rgba(217, 154, 78, 0.16); }

.thumbnail-list { padding: 12px; }

.thumbnail {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  margin-bottom: 8px;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 8px;
}

.thumbnail:hover,
.thumbnail.is-active { background: rgba(255, 255, 255, 0.72); border-color: rgba(39, 74, 82, 0.16); }
.thumbnail.is-active { box-shadow: inset 3px 0 var(--accent); }

.thumbnail-canvas,
.thumbnail-placeholder {
  width: 78px;
  height: 110px;
  flex: 0 0 78px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 2px 9px rgba(15, 30, 34, 0.18);
}

.thumbnail-placeholder {
  background: linear-gradient(110deg, #f1f1ee 20%, #fff 45%, #f1f1ee 70%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
}

.thumbnail-label { min-width: 0; display: grid; gap: 5px; }
.thumbnail-label strong { color: #8f622e; font-size: 11px; }
.thumbnail-label span { overflow: hidden; color: #30464a; font-size: 12px; font-weight: 700; text-overflow: ellipsis; }

.viewer-main {
  min-width: 0;
  min-height: 0;
  position: relative;
  flex: 1;
  display: grid;
  grid-template-rows: minmax(0, 1fr) 66px;
}

.document-stage {
  min-width: 0;
  min-height: 0;
  position: relative;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-color: rgba(220, 226, 225, 0.45) transparent;
  scrollbar-width: thin;
  perspective: 1600px;
}

.spread-shell {
  width: max-content;
  min-width: 100%;
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px 42px;
  margin: auto;
  transform-style: preserve-3d;
  will-change: transform, opacity, filter;
}

.page-transition.is-forward {
  transform-origin: 18% 50%;
  animation: page-turn-forward 440ms cubic-bezier(0.22, 0.72, 0.18, 1) both;
}

.page-transition.is-backward {
  transform-origin: 82% 50%;
  animation: page-turn-backward 440ms cubic-bezier(0.22, 0.72, 0.18, 1) both;
}

.page-frame {
  position: relative;
  flex: 0 0 auto;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 12px 36px rgba(3, 11, 13, 0.38), 0 0 0 1px rgba(255, 255, 255, 0.14);
}

.page-frame canvas { display: block; max-width: none; }
.page-frame.is-compact { box-shadow: none; }
.page-frame.is-compact canvas { max-width: 78px; max-height: 110px; object-fit: contain; }

.page-loading {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: grid;
  place-items: center;
  color: #8d704d;
  background: #eeeee9;
}

.page-loading svg,
.page-loading i,
.load-screen svg,
.search-status svg,
.panel-empty svg { animation: spin 1s linear infinite; }

.page-number-chip {
  position: absolute;
  right: 8px;
  bottom: 8px;
  min-width: 28px;
  padding: 5px 7px;
  color: #fff;
  text-align: center;
  background: rgba(19, 39, 44, 0.7);
  border-radius: 999px;
  opacity: 0;
  font-size: 10px;
  font-weight: 700;
  transition: opacity 150ms ease;
}

.page-frame:hover .page-number-chip { opacity: 1; }

.edge-control {
  width: 52px;
  height: 86px;
  position: absolute;
  z-index: 8;
  top: 50%;
  display: grid;
  place-items: center;
  padding: 0;
  color: rgba(255, 255, 255, 0.62);
  background: rgba(11, 29, 34, 0.16);
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  transform: translateY(-50%);
  transition: all 160ms ease;
}

.edge-control:hover { color: #fff; background: rgba(11, 29, 34, 0.52); border-color: rgba(255, 255, 255, 0.1); }
.edge-control i { font-size: 29px; }
.edge-control:disabled { opacity: 0.16; cursor: default; }
.edge-prev { left: 3px; }
.edge-next { right: 3px; }

.toolbar {
  position: relative;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 8px 14px 10px;
  color: #fff;
  background: rgba(19, 45, 51, 0.72);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
}

.toolbar-group { gap: 2px; }
.toolbar-divider { width: 1px; height: 28px; background: rgba(255, 255, 255, 0.2); }

.fit-button {
  min-width: 54px;
  padding: 0 6px;
  color: rgba(255, 255, 255, 0.76);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.mobile-page-label {
  display: none;
  min-width: 60px;
  color: rgba(255, 255, 255, 0.8);
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.load-screen,
.error-screen {
  height: 100%;
  min-height: 360px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  color: rgba(255, 255, 255, 0.76);
}

.load-brand { margin-bottom: 16px; color: #e9d2ae; font-size: 20px; font-weight: 700; letter-spacing: 0.22em; }
.load-screen strong,
.error-screen strong { color: #fff; font-size: 14px; }
.load-screen small { font-variant-numeric: tabular-nums; }

.progress-track {
  width: min(230px, 60vw);
  height: 3px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 99px;
}

.progress-track span { height: 100%; display: block; background: var(--accent-soft); transition: width 180ms ease; }

.error-screen a,
.error-screen button {
  height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  color: #fff;
  background: #a86e31;
  border: 0;
  border-radius: 7px;
  text-decoration: none;
  cursor: pointer;
}

.search-form {
  display: flex;
  gap: 6px;
  padding: 9px;
  background: #eff1f0;
  border-bottom: 1px solid var(--panel-line);
}

.search-form input {
  min-width: 0;
  height: 39px;
  flex: 1;
  padding: 0 12px;
  color: #273b3f;
  background: #fff;
  border: 1px solid #aeb8b9;
  border-radius: 4px;
}

.search-form button {
  width: 42px;
  display: grid;
  place-items: center;
  color: #fff;
  background: #2f4d54;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
}

.search-status {
  min-height: 38px;
  gap: 7px;
  padding: 8px 12px;
  color: #4d5d60;
  background: #d9dedd;
  border-bottom: 1px solid #c1c9c9;
  font-size: 12px;
}

.search-results button {
  width: 100%;
  display: grid;
  gap: 6px;
  padding: 13px 14px 15px;
  text-align: left;
  border-bottom: 1px solid var(--panel-line);
}

.search-results button:hover { background: #f8f8f6; }
.result-heading { justify-content: space-between; color: #607175; font-size: 11px; }
.result-heading strong { color: #2f4d54; }
.result-title { color: #24393d; font-size: 13px; font-weight: 700; }

.result-snippet {
  display: -webkit-box;
  overflow: hidden;
  color: #506064;
  font-size: 12px;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}

.result-snippet mark { padding: 1px 2px; color: #31200e; background: #f4c47d; border-radius: 2px; }

.panel-empty {
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 26px;
  color: #657477;
  text-align: center;
  font-size: 13px;
}

.keyboard-hint {
  position: fixed;
  z-index: 20;
  right: 18px;
  bottom: 103px;
  display: flex;
  gap: 5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}

.viewer-app:hover .keyboard-hint { opacity: 0.65; }

.keyboard-hint span {
  padding: 5px 7px;
  color: #d8e0df;
  background: rgba(8, 24, 28, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 5px;
  font-size: 9px;
}

.credit-footer {
  position: relative;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 0 12px;
  color: rgba(222, 229, 228, 0.62);
  background: #0c2227;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 10.5px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.credit-footer a {
  margin: 0 3px;
  color: #e3b16e;
  font-weight: 700;
  text-decoration: none;
}

.credit-footer .credit-partner {
  margin: 0 3px;
  color: #e3b16e;
  font-weight: 700;
}

.credit-footer a:hover {
  color: #ffd9a7;
  text-decoration: underline;
  text-underline-offset: 2px;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position: -200% 0; } }

@keyframes page-turn-forward {
  0% {
    opacity: 0.18;
    filter: brightness(0.72) blur(1.5px);
    transform: translateX(34px) rotateY(-7deg) scale(0.986);
  }
  58% {
    opacity: 1;
    filter: brightness(1.04) blur(0);
    transform: translateX(-4px) rotateY(1deg) scale(1.002);
  }
  100% {
    opacity: 1;
    filter: none;
    transform: translateX(0) rotateY(0) scale(1);
  }
}

@keyframes page-turn-backward {
  0% {
    opacity: 0.18;
    filter: brightness(0.72) blur(1.5px);
    transform: translateX(-34px) rotateY(7deg) scale(0.986);
  }
  58% {
    opacity: 1;
    filter: brightness(1.04) blur(0);
    transform: translateX(4px) rotateY(-1deg) scale(1.002);
  }
  100% {
    opacity: 1;
    filter: none;
    transform: translateX(0) rotateY(0) scale(1);
  }
}

@media (max-width: 1180px) {
  .side-panel { position: absolute; z-index: 25; top: 0; bottom: 0; left: 0; }
  .search-panel { right: 0; left: auto; }
  .document-title span { display: none; }
}

@media (max-width: 740px) {
  .viewer-app { min-height: 420px; grid-template-rows: 52px minmax(0, 1fr) 26px; }
  .topbar { grid-template-columns: auto 1fr auto; gap: 6px; min-height: 52px; padding: 0 5px; }
  .document-title { display: none; }
  .doc-switch { margin-left: 0; }
  .doc-switch a { height: 28px; padding: 0 9px; font-size: 12px; }
  .doc-long { display: none; }
  .doc-short { display: inline; }
  .page-control { gap: 5px; }
  .page-control > span:first-child,
  .zoom-readout { display: none; }
  .page-control input { width: 53px; height: 32px; }
  .side-panel,
  .search-panel { width: min(90vw, 340px); flex-basis: min(90vw, 340px); }
  .viewer-main { grid-template-rows: minmax(0, 1fr) 59px; }
  .spread-shell { padding: 12px 30px; }
  .edge-control { width: 32px; height: 66px; background: transparent; }
  .edge-control svg { width: 30px; }
  .toolbar { gap: 2px; padding: 5px 4px 7px; }
  .toolbar .icon-button { min-width: 34px; width: 34px; }
  .toolbar-divider,
  .secondary-tools .icon-button:nth-child(2),
  .secondary-tools .icon-button:nth-child(4),
  .secondary-tools .icon-button:nth-child(5),
  .zoom-tools .icon-button:last-child,
  .fit-button { display: none; }
  .mobile-page-label { display: inline-block; }
  .keyboard-hint { display: none; }
  .credit-footer { font-size: 9.5px; }
}

@media (max-width: 410px) {
  .nav-tools .icon-button:first-child,
  .nav-tools .icon-button:last-child,
  .secondary-tools .icon-button:first-child { display: none; }
  .toolbar { justify-content: space-around; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
