:root {
  --paper: #f7efe2;
  --ink: #2f221a;
  --muted: #7b6759;
  --brand: #7a5136;
  --brand-dark: #4e321f;
  --rose: #c6817d;
  --green: #657a62;
  --line: rgba(72, 49, 32, .16);
  --shadow: 0 22px 70px rgba(45, 30, 18, .22);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  line-height: 1.5;
  background:
    radial-gradient(circle at top left, rgba(198,129,125,.20), transparent 30rem),
    linear-gradient(135deg, #fff9ef 0%, #f3e2c8 44%, #d9bfa0 100%);
  min-height: 100vh;
  background-attachment: fixed;
}
::selection { background: rgba(122,81,54,.2); color: var(--ink); }
button, input, textarea, select { font: inherit; }
button { border: 0; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
.btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.app-shell { min-height: 100vh; padding: 18px; padding-top: max(18px, env(safe-area-inset-top)); padding-bottom: max(18px, env(safe-area-inset-bottom)); }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 1180px; margin: 0 auto 16px; padding: 12px 0;
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 800; letter-spacing: .04em; }
.brand-mark { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: linear-gradient(145deg, var(--brand), var(--rose)); box-shadow: 0 8px 22px rgba(122,81,54,.28); overflow: hidden; }
.brand-mark img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; }
.btn { min-height: 42px; padding: 0 14px; border-radius: 999px; background: #fff8ef; color: var(--ink); border: 1px solid var(--line); box-shadow: 0 6px 18px rgba(75,48,28,.08); transition: all .15s ease; }
.btn:hover { box-shadow: 0 8px 24px rgba(75,48,28,.14); transform: translateY(-1px); }
.btn.primary { background: var(--brand); color: white; border-color: transparent; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: #9b2727; }
.btn.danger:hover { background: rgba(155,39,39,.08); }
.btn.icon { width: 42px; padding: 0; display: inline-grid; place-items: center; font-size: 20px; font-weight: 300; }
.grid { max-width: 1180px; margin: 0 auto; display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 18px; align-items: start; }
.panel { background: rgba(255, 250, 242, .82); border: 1px solid rgba(122,81,54,.15); border-radius: 18px; box-shadow: 0 12px 40px rgba(70,42,24,.10); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
.panel-pad { padding: 18px; }
.home { max-width: 1060px; margin: 0 auto; }
.hero {
  min-height: 300px; display: grid; align-content: end; padding: 40px; border-radius: 24px; color: white;
  background: linear-gradient(rgba(43,28,18,.3), rgba(43,28,18,.65)),
    repeating-linear-gradient(45deg, transparent, transparent 2px, rgba(255,255,255,.015) 2px, rgba(255,255,255,.015) 4px),
    linear-gradient(135deg, #5c3d2e, #8b6b4f, #a68b6b);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: ''; position: absolute; top: -40%; right: -10%; width: 300px; height: 300px;
  background: radial-gradient(circle, rgba(198,129,125,.35), transparent 70%);
  pointer-events: none;
}
.hero h1 { margin: 0 0 8px; font-family: Georgia, serif; font-size: clamp(34px, 8vw, 76px); line-height: .95; }
.hero p { margin: 0; max-width: 620px; font-size: 17px; color: rgba(255,255,255,.86); }
.album-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-top: 18px; }
.album-card { padding: 14px; text-align: left; border-radius: 18px; background: rgba(255,250,242,.80); border: 1px solid var(--line); box-shadow: 0 12px 32px rgba(73,45,25,.12); transition: transform .2s ease, box-shadow .2s ease; }
.album-card:hover { transform: translateY(-2px); box-shadow: 0 16px 40px rgba(73,45,25,.18); }
.album-card h3 { margin: 10px 0 6px; font-size: 15px; font-weight: 700; line-height: 1.2; }
.cover-mini {
  aspect-ratio: 3/4; border-radius: 12px; padding: 18px; display: grid; align-content: center; justify-items: center; text-align: center; color: #fff;
  background: linear-gradient(145deg, #6b4a35, #8b6b4f);
  box-shadow: inset 18px 0 20px rgba(0,0,0,.16), 0 10px 24px rgba(0,0,0,.14);
  overflow: hidden; transition: transform .2s ease; position: relative;
}
.cover-mini::after {
  content: ''; position: absolute; top: 0; right: 0; width: 3px; height: 100%;
  background: linear-gradient(180deg, rgba(255,255,255,.15), transparent, rgba(0,0,0,.1));
}
.cover-mini:hover { transform: scale(1.02); }
.cover-mini img { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: 8px; margin-bottom: 10px; }
.cover-mini strong { font-family: Georgia, serif; font-size: 22px; line-height: 1.05; text-shadow: 0 2px 8px rgba(0,0,0,.25); }
.cover-mini span { display: block; font-size: 13px; opacity: .75; margin-top: 4px; }
.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 12px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.field input, .field textarea, .field select { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; background: rgba(255,255,255,.82); color: var(--ink); outline: none; transition: border-color .15s ease; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--brand); }
.field textarea { min-height: 96px; resize: vertical; }
.page-tabs { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 12px; overscroll-behavior: contain; scroll-behavior: smooth; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.page-tab { flex: 0 0 auto; border-radius: 999px; padding: 9px 13px; background: rgba(255,255,255,.7); border: 1px solid var(--line); color: var(--ink); transition: all .15s ease; }
.page-tab.active { background: var(--brand); color: #fff; }
.editor-tabs { display: flex; gap: 0; max-width: 1180px; margin: 0 auto 14px; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); background: rgba(255,250,242,.6); }
.editor-tab { flex: 1; padding: 12px; text-align: center; font-weight: 700; font-size: 14px; border: none; background: transparent; color: var(--muted); cursor: pointer; transition: all .15s ease; }
.editor-tab.active { background: var(--brand); color: #fff; }
.editor-tab:hover:not(.active) { background: rgba(122,81,54,.08); }
.book-editor, .book-view { min-height: 620px; padding: 18px; display: flex; align-items: center; justify-content: center; }
.book-view {
  user-select: none; -webkit-user-select: none; touch-action: pan-y;
  perspective: 2200px; perspective-origin: 50% 50%;
}
.book {
  position: relative; display: grid; grid-template-columns: 1fr 1fr;
  width: 100%; height: min(78vh, 580px);
  max-width: 900px; max-height: 580px;
  overflow: hidden;
  border-radius: 14px; background: #faf5ed; box-shadow: var(--shadow);
  transform-style: preserve-3d;
  transform-origin: 50% 50%;
}
.book::before {
  content: ''; position: absolute; top: 0; bottom: 0; left: 0; width: 14px; z-index: 2;
  background: linear-gradient(90deg, rgba(90,60,40,.3), rgba(90,60,40,.15), transparent);
  border-radius: 14px 0 0 14px; pointer-events: none;
}
.book::after {
  content: ''; position: absolute; top: 0; bottom: 0; left: 50%; width: 46px; transform: translateX(-50%);
  background: linear-gradient(90deg, transparent, rgba(0,0,0,.18), rgba(255,255,255,.2), rgba(0,0,0,.18), transparent);
  pointer-events: none; z-index: 3;
}
.page-photo, .page-memory { min-width: 0; padding: 18px; position: relative; }
.page-photo { background: rgba(0,0,0,.025); overflow: hidden; display: grid; place-items: center; }
.photo-frame {
  width: 100%; height: 100%; min-height: 0; border-radius: 8px; overflow: hidden;
  background: rgba(255,255,255,.3); display: grid; place-items: center; position: relative;
  box-shadow: inset 0 1px 3px rgba(0,0,0,.05);
}
.photo-frame img { max-width: 100%; max-height: 100%; object-fit: contain; transform-origin: center; user-select: none; pointer-events: none; }
.empty-photo { color: rgba(47,34,26,.3); display: grid; place-items: center; text-align: center; gap: 10px; }
.memory-inner { height: 100%; display: flex; flex-direction: column; text-align: center; align-items: center; justify-content: flex-start; padding-top: 20px; gap: 16px; }
.memory-inner h2 { margin: 0; font-family: Georgia, serif; font-size: clamp(22px, 3.5vw, 38px); line-height: 1.1; min-height: 1.1em; }
.memory-inner .date { color: #5a4535; font-weight: 600; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; margin-top: auto; }
.memory-text { flex: 1; overflow: auto; padding: 0 8px; line-height: 1.7; color: #3a2a1e; white-space: pre-wrap; overflow-wrap: break-word; font-size: 14px; min-height: 60px; overscroll-behavior: contain; }
.tune { margin-top: 8px; display: grid; justify-items: center; gap: 8px; width: min(200px, 100%); }
.record {
  width: 90px; height: 90px; border-radius: 50%;
  background: radial-gradient(circle, #f4efe6 0 13%, #202020 14% 18%, #111 19% 100%);
  box-shadow: 0 12px 20px rgba(0,0,0,.22), inset 0 0 0 9px rgba(255,255,255,.025);
  position: relative; display: grid; place-items: center; color: #111;
  transition: transform .3s ease;
  will-change: transform;
}
.record::before {
  content: ''; position: absolute; inset: 10px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,.08);
  box-shadow: 0 0 0 6px rgba(255,255,255,.03), 0 0 0 12px rgba(255,255,255,.02);
}
.record-disc {
  width: 44px; height: 44px; border-radius: 50%; object-fit: cover;
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
}
.record-mg {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 0;
  font-family: Georgia, serif; font-size: 16px; font-weight: 700;
  color: #7a5136; letter-spacing: 1px;
}
.record.playing { animation: spin 2.8s linear infinite; }
.tune-controls { display: flex; align-items: center; gap: 6px; justify-content: center; }
.play-inline {
  width: 28px; height: 28px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--brand); color: #fff; font-size: 11px;
  display: grid; place-items: center; flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0,0,0,.15); transition: transform .1s ease;
}
.play-inline:active { transform: scale(0.9); }
.time-display { font-size: 10px; color: #555; white-space: nowrap; font-family: monospace; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes spin-reverse { to { transform: rotate(-360deg); } }
.tune-title { max-width: 200px; font-size: 12px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tune-progress { width: 100%; height: 3px; background: rgba(0,0,0,.1); border-radius: 2px; overflow: hidden; margin-top: 4px; }
.tune-progress-bar { width: 0%; height: 100%; background: var(--brand); border-radius: 2px; transition: width .3s linear; }
.photo-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.photo-tools .btn { min-height: 36px; padding: 0 10px; flex: 0 0 auto; }

/* === PHOTO EDITOR FILTER TOOLS === */
.filter-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.filter-btn {
  min-height: 32px; padding: 0 10px; border-radius: 999px; font-size: 11px; font-weight: 600;
  background: rgba(255,255,255,.7); border: 1px solid var(--line); color: var(--ink);
  transition: all .15s ease; cursor: pointer;
}
.filter-btn:hover { background: rgba(122,81,54,.08); }
.filter-btn.active { background: var(--brand); color: #fff; border-color: transparent; }

/* === VIEWER === */
.viewer { min-height: 100vh; display: grid; grid-template-rows: auto 1fr auto; }
.viewer-stage { display: grid; place-items: center; padding: 12px; }
.cover-large {
  width: min(85vw, 480px); aspect-ratio: 3/4; border-radius: 18px; color: white; padding: 32px;
  display: grid; align-content: center; justify-items: center; text-align: center;
  background: linear-gradient(145deg, #5c3d2e, #8b6b4f);
  box-shadow: inset 28px 0 25px rgba(0,0,0,.18), var(--shadow);
  position: relative; overflow: hidden; transition: transform .3s ease;
}
.cover-large::before {
  content: ''; position: absolute; top: 0; right: 0; width: 4px; height: 100%;
  background: linear-gradient(180deg, rgba(255,255,255,.12), transparent, rgba(0,0,0,.08));
}
.cover-large:hover { transform: scale(1.01); }
.cover-large h1 { font-family: Georgia, serif; font-size: clamp(30px, 8vw, 56px); line-height: 1; margin: 0 0 10px; }
.cover-large p { font-size: 15px; opacity: .85; margin: 0 0 6px; }
.cover-large small { opacity: .65; font-size: 12px; }
.navbar { display: flex; justify-content: center; align-items: center; gap: 14px; padding: 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }

/* === 3D FLIP ANIMATIONS === */
.flip-next { animation: flipRight .7s cubic-bezier(0.4, 0, 0.2, 1) both; transform-origin: 50% 50%; }
.flip-prev { animation: flipLeft .7s cubic-bezier(0.4, 0, 0.2, 1) both; transform-origin: 50% 50%; }

@keyframes flipRight {
  0% { transform: rotateY(0deg); box-shadow: var(--shadow); }
  20% { transform: rotateY(-12deg); box-shadow: 12px 4px 30px rgba(0,0,0,.2), 20px 8px 50px rgba(0,0,0,.1); }
  50% { transform: rotateY(-25deg); box-shadow: 20px 10px 50px rgba(0,0,0,.25), 35px 18px 70px rgba(0,0,0,.12); }
  80% { transform: rotateY(-8deg); box-shadow: 8px 4px 20px rgba(0,0,0,.15), 12px 6px 30px rgba(0,0,0,.08); }
  100% { transform: rotateY(0deg); box-shadow: var(--shadow); }
}

@keyframes flipLeft {
  0% { transform: rotateY(0deg); box-shadow: var(--shadow); }
  20% { transform: rotateY(12deg); box-shadow: -12px 4px 30px rgba(0,0,0,.2), -20px 8px 50px rgba(0,0,0,.1); }
  50% { transform: rotateY(25deg); box-shadow: -20px 10px 50px rgba(0,0,0,.25), -35px 18px 70px rgba(0,0,0,.12); }
  80% { transform: rotateY(8deg); box-shadow: -8px 4px 20px rgba(0,0,0,.15), -12px 6px 30px rgba(0,0,0,.08); }
  100% { transform: rotateY(0deg); box-shadow: var(--shadow); }
}

/* Page transition wrapper */
.page-transition-wrapper { position: relative; width: 100%; height: 100%; }
.flip-exit-next { animation: flipExitRight .7s cubic-bezier(0.4, 0, 0.2, 1) forwards; transform-origin: left center; }
.flip-exit-prev { animation: flipExitLeft .7s cubic-bezier(0.4, 0, 0.2, 1) forwards; transform-origin: right center; }
.flip-enter-next { animation: flipEnterNext .7s cubic-bezier(0.4, 0, 0.2, 1) forwards; transform-origin: right center; }
.flip-enter-prev { animation: flipEnterPrev .7s cubic-bezier(0.4, 0, 0.2, 1) forwards; transform-origin: left center; }

@keyframes flipExitRight {
  0% { transform: rotateY(0deg); opacity: 1; }
  100% { transform: rotateY(-90deg); opacity: 0; }
}
@keyframes flipExitLeft {
  0% { transform: rotateY(0deg); opacity: 1; }
  100% { transform: rotateY(90deg); opacity: 0; }
}
@keyframes flipEnterNext {
  0% { transform: rotateY(90deg); opacity: 0; }
  100% { transform: rotateY(0deg); opacity: 1; }
}
@keyframes flipEnterPrev {
  0% { transform: rotateY(-90deg); opacity: 0; }
  100% { transform: rotateY(0deg); opacity: 1; }
}

/* === TOAST === */
.toast {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: rgba(47,34,26,.92); color: white; padding: 12px 16px; border-radius: 999px;
  pointer-events: none; transition: .22s ease; z-index: 50;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.yt-host { position: fixed; width: 1px; height: 1px; left: -20px; bottom: -20px; opacity: 0; pointer-events: none; }
hr { border: none; border-top: 1px solid var(--line); margin: 16px 0; }

/* Cover book — album feel */
.cover-book-wrap { width: 100%; max-width: 440px; margin: 20px auto 0; perspective: 800px; }
.cover-book {
  position: relative; width: 100%; aspect-ratio: 3/4; border-radius: 6px 16px 16px 6px;
  transform-style: preserve-3d; transform: rotateY(-3deg);
  transition: transform .4s ease;
  background:
    repeating-linear-gradient(45deg, transparent, transparent 2px, rgba(255,255,255,.012) 2px, rgba(255,255,255,.012) 4px),
    linear-gradient(145deg, #5c3d2e, #7a5136, #8b6b4f);
}
.cover-book:hover { transform: rotateY(0deg) scale(1.01); }
.cover-book::after {
  content: ''; position: absolute; top: 0; right: 0; width: 8px; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(0,0,0,.08));
  border-radius: 0 16px 16px 0; z-index: 4;
  transform: translateZ(1px);
}
.cover-book-inner {
  width: 100%; height: 100%; border-radius: 6px 16px 16px 6px; overflow: hidden;
  box-shadow:
    4px 4px 14px rgba(0,0,0,.22),
    -2px 0 10px rgba(0,0,0,.12),
    inset 0 1px 0 rgba(255,255,255,.08),
    inset 0 -1px 0 rgba(0,0,0,.15);
  position: relative; z-index: 1;
}
.cover-photo-wrap { width: 100%; height: 100%; position: relative; }
.cover-photo-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; filter: contrast(1.08) saturate(1.1); }
.cover-text-overlay {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 24px 20px;
  background: linear-gradient(transparent, rgba(0,0,0,.6));
  color: #fff; text-align: center;
  border-radius: 0 0 16px 16px;
}
.cover-default-bg {
  width: 100%; height: 100%; color: #fff; font-family: Georgia, serif;
  background: linear-gradient(160deg, #5c3d2e 0%, #7a5136 30%, #8b6b4f 60%, #a68b6b 100%);
  display: grid; place-items: center; position: relative;
}
.cover-default-bg::before {
  content: ''; position: absolute; inset: 0;
  background: repeating-linear-gradient(45deg, transparent, transparent 3px, rgba(255,255,255,.02) 3px, rgba(255,255,255,.02) 6px);
  pointer-events: none;
}
.cover-book-spine {
  position: absolute; top: 0; left: -10px; width: 16px; height: 100%;
  background: linear-gradient(90deg,
    rgba(35,20,10,.85),
    rgba(60,38,22,.65) 25%,
    rgba(80,52,32,.45) 50%,
    rgba(70,45,28,.25) 75%,
    transparent);
  border-radius: 6px 0 0 6px; z-index: 2;
  transform: translateZ(-2px) rotateY(-8deg);
  transform-origin: right center;
  box-shadow:
    inset -3px 0 6px rgba(0,0,0,.3),
    inset 2px 0 3px rgba(255,255,255,.05),
    -4px 0 8px rgba(0,0,0,.15);
}
.cover-book-edge {
  position: absolute; top: 2px; right: -1px; width: 6px; height: calc(100% - 4px);
  background:
    repeating-linear-gradient(0deg,
      #f5efe4 0px, #f5efe4 1px,
      #e8dfd0 1px, #e8dfd0 2px,
      #f0e8d8 2px, #f0e8d8 3px);
  border-radius: 0 4px 4px 0; z-index: 3;
  box-shadow: 1px 0 2px rgba(0,0,0,.1);
}
.cover-book-shadow {
  position: absolute; bottom: -14px; left: 6px; right: 2px; height: 24px;
  background: radial-gradient(ellipse at center, rgba(0,0,0,.22), transparent 65%);
  filter: blur(8px); z-index: 0;
}

/* Viewer cover */
.viewer-cover-photo {
  width: 100%; height: 50%; overflow: hidden; border-radius: 16px 16px 0 0;
}
.viewer-cover-photo img { width: 100%; height: 100%; object-fit: cover; display: block; filter: contrast(1.08) saturate(1.1); }
.viewer-cover-default {
  width: 100%; aspect-ratio: 3/4; max-width: 480px; margin: 0 auto 18px;
  border-radius: 16px; color: #fff; font-family: Georgia, serif;
  background: linear-gradient(160deg, #5c3d2e 0%, #7a5136 30%, #8b6b4f 60%, #a68b6b 100%);
  display: grid; place-items: center; position: relative;
  box-shadow: inset 28px 0 25px rgba(0,0,0,.18), var(--shadow);
}
.viewer-cover-default::before {
  content: ''; position: absolute; inset: 0; border-radius: 16px;
  background: repeating-linear-gradient(45deg, transparent, transparent 3px, rgba(255,255,255,.02) 3px, rgba(255,255,255,.02) 6px);
  pointer-events: none;
}
.cover-text { position: absolute; bottom: 0; left: 0; right: 0; padding: 24px; background: linear-gradient(transparent, rgba(0,0,0,.5)); border-radius: 0 0 16px 16px; text-align: center; }

/* YouTube search results */
.yt-results { margin-top: 8px; }
.yt-loading { padding: 16px; text-align: center; color: var(--muted); font-size: 13px; }
.yt-empty { padding: 16px; text-align: center; color: var(--muted); font-size: 13px; }
.yt-list { display: flex; flex-direction: column; gap: 6px; max-height: 300px; overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; padding: 6px; background: rgba(255,255,255,.6); }
.yt-item {
  display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px;
  background: transparent; border: none; cursor: pointer; text-align: left; width: 100%;
  transition: background .15s ease;
}
.yt-item:hover { background: rgba(122,81,54,.08); }
.yt-thumb { width: 48px; height: 36px; border-radius: 6px; object-fit: cover; flex-shrink: 0; background: #ddd; }
.yt-info { min-width: 0; flex: 1; }
.yt-title { font-size: 13px; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.yt-channel { font-size: 11px; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Scrollbar */
.page-tabs::-webkit-scrollbar,
.memory-text::-webkit-scrollbar { width: 6px; height: 6px; }
.page-tabs::-webkit-scrollbar-track,
.memory-text::-webkit-scrollbar-track { background: transparent; }
.page-tabs::-webkit-scrollbar-thumb,
.memory-text::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

@media (prefers-reduced-motion: reduce) {
  .record.playing { animation: none; }
  .record.playing button { animation: none; }
  .flip-next, .flip-prev { animation: none !important; opacity: 1 !important; transform: none !important; }
  .flip-exit-next, .flip-exit-prev, .flip-enter-next, .flip-enter-prev { animation: none !important; }
  * { transition-duration: 0.01ms !important; }
}

@media (display-mode: standalone) {
  .app-shell { padding-top: max(18px, env(safe-area-inset-top)); }
}

@media (max-width: 860px) {
  .app-shell { padding: 10px; padding-top: max(10px, env(safe-area-inset-top)); }
  .topbar { align-items: flex-start; flex-direction: column; gap: 8px; }
  .grid { grid-template-columns: 1fr; }
  .hero { min-height: 220px; padding: 24px; }
  .hero h1 { font-size: clamp(28px, 8vw, 48px); }
  .actions { width: 100%; justify-content: flex-start; flex-wrap: wrap; }
  .album-card { padding: 10px; }
  .cover-large { width: min(92vw, 420px); }
  .viewer-stage { padding: 8px; }
  .flip-next, .flip-prev { animation-duration: .5s; }
  .filter-tools { gap: 4px; }
  .filter-btn { font-size: 10px; min-height: 28px; padding: 0 8px; }
}

/* Mobil dikey (portrait) - defter ortada, yatay kitap, ekrana sığsın */
@media (max-width: 860px) and (orientation: portrait) {
  .app-shell { overflow: hidden; }
  .book-editor, .book-view {
    padding: 8px;
    min-height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
  }
  .book-view { perspective: 1800px; }
  .book {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr;
    width: 96vw;
    max-width: 560px;
    height: 56vw;
    max-height: 420px;
    overflow: hidden;
  }
  .book::before {
    display: block;
    content: ''; position: absolute; top: 0; bottom: 0; left: 0; width: 10px; z-index: 2;
    background: linear-gradient(90deg, rgba(90,60,40,.25), rgba(90,60,40,.1), transparent);
    border-radius: 10px 0 0 10px; pointer-events: none;
  }
  .book::after {
    display: block;
    content: ''; position: absolute; top: 0; bottom: 0; left: 50%; width: 30px; transform: translateX(-50%);
    background: linear-gradient(90deg, transparent, rgba(0,0,0,.12), rgba(255,255,255,.15), rgba(0,0,0,.12), transparent);
    pointer-events: none; z-index: 3;
  }
  .page-photo {
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    padding: 10px;
  }
  .page-memory {
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    padding: 10px;
  }
  .photo-frame {
    min-height: 0;
    height: 100%;
    overflow: hidden;
  }
  .photo-frame img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
  }
  .memory-inner {
    padding-top: 8px;
    gap: 6px;
    height: 100%;
    overflow: hidden;
  }
  .memory-inner h2 {
    font-size: clamp(14px, 3.2vw, 22px);
  }
  .memory-text {
    font-size: 11px;
    padding: 0 4px;
    overflow: hidden;
    flex: 1;
    min-height: 0;
  }
  .tune {
    margin-top: 4px;
    gap: 4px;
  }
  .record {
    width: 56px;
    height: 56px;
  }
  .record-disc {
    width: 28px;
    height: 28px;
  }
}

/* Mobil yatay (landscape) - defter ortada, geniş, ekrana sığsın */
@media (max-width: 860px) and (orientation: landscape) {
  .app-shell { overflow: hidden; }
  .book-editor, .book-view {
    padding: 6px;
    min-height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
  }
  .book-view { perspective: 1800px; }
  .book {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr;
    width: 95vw;
    max-width: 620px;
    height: 88vh;
    max-height: 500px;
    overflow: hidden;
  }
  .book::before {
    display: block;
    content: ''; position: absolute; top: 0; bottom: 0; left: 0; width: 10px; z-index: 2;
    background: linear-gradient(90deg, rgba(90,60,40,.25), rgba(90,60,40,.1), transparent);
    border-radius: 10px 0 0 10px; pointer-events: none;
  }
  .book::after {
    display: block;
    content: ''; position: absolute; top: 0; bottom: 0; left: 50%; width: 30px; transform: translateX(-50%);
    background: linear-gradient(90deg, transparent, rgba(0,0,0,.12), rgba(255,255,255,.15), rgba(0,0,0,.12), transparent);
    pointer-events: none; z-index: 3;
  }
  .page-photo {
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    padding: 10px;
  }
  .page-memory {
    min-height: 0;
    min-width: 0;
    overflow: hidden;
    padding: 10px;
  }
  .photo-frame {
    min-height: 0;
    height: 100%;
    overflow: hidden;
  }
  .photo-frame img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
  }
  .memory-inner {
    padding-top: 10px;
    gap: 8px;
    height: 100%;
    overflow: hidden;
  }
  .memory-inner h2 {
    font-size: clamp(16px, 3vw, 24px);
  }
  .memory-text {
    font-size: 12px;
    overflow: hidden;
    flex: 1;
    min-height: 0;
  }
  .tune {
    margin-top: 4px;
    gap: 4px;
  }
  .record {
    width: 56px;
    height: 56px;
  }
  .record-disc {
    width: 28px;
    height: 28px;
  }
}
  .book-view { perspective: 1800px; }
  .book {
    grid-template-columns: 1fr 1fr;
    width: 95vw;
    max-width: 620px;
    height: 90vh;
    overflow: hidden;
  }
  .book::before {
    display: block;
    content: ''; position: absolute; top: 0; bottom: 0; left: 0; width: 10px; z-index: 2;
    background: linear-gradient(90deg, rgba(90,60,40,.25), rgba(90,60,40,.1), transparent);
    border-radius: 10px 0 0 10px; pointer-events: none;
  }
  .book::after {
    display: block;
    content: ''; position: absolute; top: 0; bottom: 0; left: 50%; width: 30px; transform: translateX(-50%);
    background: linear-gradient(90deg, transparent, rgba(0,0,0,.12), rgba(255,255,255,.15), rgba(0,0,0,.12), transparent);
    pointer-events: none; z-index: 3;
  }
  .page-photo {
    min-height: 0;
    height: 100%;
    padding: 8px;
    overflow: hidden;
  }
  .page-memory {
    min-height: 0;
    height: 100%;
    padding: 8px;
    overflow: hidden;
  }
  .photo-frame {
    min-height: 0;
    height: 100%;
  }
  .photo-frame img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
  }
  .memory-inner {
    height: 100%;
    padding-top: 8px;
    gap: 6px;
  }
  .memory-inner h2 {
    font-size: clamp(14px, 2.8vw, 22px);
  }
  .memory-text {
    font-size: 12px;
    overflow: hidden;
  }
  .tune {
    margin-top: auto;
    gap: 3px;
  }
  .record {
    width: 50px;
    height: 50px;
  }
  .record-disc {
    width: 24px;
    height: 24px;
  }
}
