:root {
  --blue-950: #073662;
  --blue-900: #0a477b;
  --green-700: #0f8a55;
  --green-600: #18a565;
  --ink: #10233b;
  --app-height: 100vh;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #071a2f;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  background:
    radial-gradient(circle at 18% 10%, rgba(24, 165, 101, 0.22), transparent 32%),
    linear-gradient(135deg, #071a2f 0%, #102f52 48%, #071a2f 100%);
}

body.portfolio-reader-open {
  overflow: hidden;
}

button,
a {
  font: inherit;
}

.portfolio-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 74px;
  padding: 14px clamp(18px, 4vw, 54px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(7, 28, 50, 0.88);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: #ffffff;
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0;
}

.brand-mark {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.portfolio-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.ghost-link,
.button-demo,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  color: #ffffff;
  text-decoration: none;
  font-weight: 800;
}

.ghost-link,
.icon-button {
  background: rgba(255, 255, 255, 0.08);
}

.button-demo {
  border-color: transparent;
  background: linear-gradient(135deg, var(--green-700), var(--green-600));
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.18);
}

.portfolio-shell {
  width: min(1500px, calc(100% - 36px));
  margin: 0 auto;
  padding: clamp(26px, 4vw, 48px) 0 42px;
}

.portfolio-intro {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: clamp(18px, 2.5vw, 30px);
  color: #ffffff;
}

.portfolio-intro p {
  margin: 0 0 10px;
  color: #7be4a4;
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.portfolio-intro h1 {
  margin: 0;
  max-width: 780px;
  font-size: clamp(2.2rem, 4.6vw, 5rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.reader {
  display: grid;
  gap: 18px;
}

.reader-toolbar {
  order: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(12px);
}

.icon-button {
  width: 46px;
  min-width: 44px;
  padding: 0;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.reader-close {
  display: none;
}

.mobile-viewer {
  display: none;
}

.icon-button:hover,
.icon-button:focus-visible,
.ghost-link:hover,
.ghost-link:focus-visible,
.button-demo:hover,
.button-demo:focus-visible {
  outline: 0;
  transform: translateY(-1px);
  border-color: rgba(123, 228, 164, 0.65);
}

.icon-button:disabled {
  opacity: 0.42;
  cursor: default;
  transform: none;
}

.page-status {
  min-width: 132px;
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 900;
  text-align: center;
}

.book-viewport {
  order: 1;
  overflow: auto;
  min-height: min(72vh, 880px);
  padding: clamp(12px, 2vw, 30px);
  border-radius: 8px;
  background: rgba(4, 17, 31, 0.42);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
  touch-action: none;
}

.book-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 100%;
  min-height: min(70vh, 850px);
  transform-origin: center center;
}

.book-stage.is-zoomed {
  cursor: grab;
  touch-action: none;
}

.mobile-page-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 100%;
  min-height: 100%;
  transform-origin: center center;
}

.mobile-page-stage.is-zoomed {
  cursor: grab;
}

.mobile-page-image {
  display: block;
  width: min(100%, 595px);
  max-height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

.portfolio-book {
  filter: drop-shadow(0 30px 44px rgba(0, 0, 0, 0.28));
  transition: transform 160ms ease;
}

.portfolio-book.is-cover-view {
  transform: translateX(-25%);
}

.portfolio-page {
  overflow: hidden;
  background: #ffffff;
}

.portfolio-page img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #ffffff;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.reader-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  height: var(--app-height);
  overflow: hidden;
  display: block;
  padding: 18px 18px 16px;
  background:
    radial-gradient(circle at 20% 12%, rgba(24, 165, 101, 0.22), transparent 34%),
    linear-gradient(135deg, #061729 0%, #12385f 100%);
}

.reader-fullscreen .reader-toolbar {
  position: fixed;
  right: 18px;
  bottom: max(16px, env(safe-area-inset-bottom));
  left: 18px;
  z-index: 1002;
  width: min(880px, calc(100% - 36px));
  margin: 0 auto;
  flex-wrap: nowrap;
  background: rgba(8, 30, 53, 0.92);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.28);
}

.reader-fullscreen .reader-toolbar [data-fullscreen] {
  display: none;
}

.reader-fullscreen .reader-close {
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  right: 18px;
  z-index: 1003;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 1px solid rgba(123, 228, 164, 0.72);
  border-radius: 8px;
  color: #ffffff;
  font-size: 1.75rem;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  background: rgba(8, 30, 53, 0.94);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.28);
}

.reader-fullscreen .book-viewport {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: calc(var(--app-height) - 92px);
  min-height: 0;
  padding: 0 0 12px;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.reader-fullscreen .book-stage {
  min-height: 100%;
}

.reader-fullscreen .portfolio-book {
  filter: drop-shadow(0 34px 56px rgba(0, 0, 0, 0.36));
}

@media (max-width: 820px) {
  .portfolio-topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .portfolio-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .portfolio-shell {
    width: min(100% - 22px, 680px);
    padding-top: 22px;
  }

  .portfolio-intro {
    display: block;
  }

  .ghost-link,
  .button-demo {
    flex: 1 1 auto;
  }

  .reader-toolbar {
    justify-content: center;
    gap: 5px;
    flex-wrap: nowrap;
    padding: 8px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .icon-button {
    flex: 0 0 36px;
    width: 36px;
    min-width: 36px;
    min-height: 36px;
    font-size: 1.22rem;
  }

  .page-status {
    flex: 0 0 58px;
    min-width: 58px;
    font-size: 0.84rem;
  }

  .book-viewport {
    display: none;
  }

  .mobile-viewer {
    order: 1;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow: hidden;
    min-height: min(72vh, 620px);
    padding: 10px;
    border-radius: 8px;
    background: rgba(4, 17, 31, 0.42);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
    touch-action: none;
  }

  .mobile-page-image {
    width: min(100%, 420px);
    height: auto;
  }

  .reader-fullscreen {
    height: var(--app-height);
    padding: 10px 10px max(10px, env(safe-area-inset-bottom));
  }

  .reader-fullscreen .reader-toolbar {
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    left: 10px;
    width: auto;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px;
  }

  .reader-fullscreen .reader-close {
    top: max(10px, env(safe-area-inset-top));
    right: 10px;
    width: 42px;
    height: 42px;
    font-size: 1.65rem;
  }

  .reader-fullscreen .book-viewport {
    display: none;
  }

  .reader-fullscreen .mobile-viewer {
    display: flex;
    width: 100%;
    height: calc(var(--app-height) - 84px);
    min-height: 0;
    padding: 0 0 8px;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  .reader-fullscreen .mobile-page-stage {
    align-items: flex-start;
    min-height: 0;
    height: 100%;
  }

  .reader-fullscreen .mobile-page-image {
    width: min(100%, 340px);
    max-height: 100%;
  }
}
