  * { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: Georgia, serif;
  background: #04070d;
  color: #eef4ff;
  min-height: 100vh;
  overflow-x: hidden;
}

  /* â”€â”€ NAV â”€â”€ */
  nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 32px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    background: linear-gradient(180deg, rgba(5, 8, 15, 0.72), rgba(5, 8, 15, 0.18));
    backdrop-filter: blur(14px);
  }
  .logo {
    font-size: 28px;
    font-weight: 300;
    font-style: italic;
    letter-spacing: 0.03em;
    color: #f8fbff;
    cursor: pointer;
    text-shadow: 0 2px 18px rgba(0, 0, 0, 0.35);
  }
  .nav-links { display: flex; gap: 32px; align-items: center; }
  .nav-link {
    font-size: 16px;
    font-family: sans-serif;
    color: rgba(244, 248, 255, 0.72);
    cursor: pointer;
    transition: color 0.15s;
    border: none;
    background: none;
    padding: 0;
  }
  .nav-link:hover { color: #f8fbff; }
  .nav-link.active { color: #f8fbff; }
  .nav-btn {
    font-size: 15px;
    font-family: sans-serif;
    padding: 10px 20px;
    border: 1px solid rgba(248, 251, 255, 0.7);
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.04);
    color: #f8fbff;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
  }
  .nav-btn:hover { background: #f8fbff; color: #07101c; }

  /* â”€â”€ PAGES â”€â”€ */
  .page { display: none; }
  .page.active { display: block; }

  /* â”€â”€ PAGE 1: PORTRAIT â”€â”€ */
  .portrait-page {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
    position: relative;
  }
  .portrait-header {
    position: absolute;
    top: 106px;
    left: 40px;
    z-index: 4;
    max-width: min(560px, calc(100vw - 420px));
  }
  .portrait-title {
    font-size: 60px;
    font-weight: 300;
    font-style: italic;
    letter-spacing: 0.02em;
    color: #f8fbff;
    margin-bottom: 8px;
    text-shadow: 0 8px 34px rgba(0, 0, 0, 0.45);
  }
  .portrait-subtitle {
    font-size: 17px;
    font-family: sans-serif;
    color: rgba(237, 244, 255, 0.82);
    margin-bottom: 0;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  .portrait-layout {
    position: relative;
    min-height: 100vh;
    display: block;
  }
  .processing-store {
    display: none;
  }

  /* memory feed */
  .memory-col {
    position: absolute;
    bottom: 32px;
    right: 32px;
    z-index: 4;
    width: min(420px, calc(100vw - 64px));
    max-height: min(320px, calc(100vh - 64px));
    padding: 18px 18px 16px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.04)),
      linear-gradient(180deg, rgba(10, 16, 28, 0.46), rgba(6, 10, 18, 0.34));
    backdrop-filter: blur(24px) saturate(120%);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.18),
      0 24px 60px rgba(0, 0, 0, 0.28);
    overflow: hidden;
    transition: opacity 0.22s ease, transform 0.22s ease, max-height 0.24s ease, width 0.24s ease;
  }
  .memory-col.is-expanded {
    width: min(420px, calc(100vw - 64px));
    max-height: calc(100vh - 120px);
    overflow: auto;
  }
  .memory-col.is-hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(18px);
  }
  .mem-stream {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .memory-col.is-expanded .mem-stream {
    display: none;
  }
  .mem-stream-label {
    font-size: 12px;
    font-family: sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: rgba(233, 241, 255, 0.62);
  }
  .mem-stream-card {
    min-height: 112px;
    padding: 2px 0;
    cursor: pointer;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.4s ease, transform 0.4s ease;
    outline: none;
  }
  .mem-stream-card.is-visible {
    opacity: 1;
    transform: translateY(0);
  }
  .mem-stream-actions,
  .mem-head-actions {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .mem-head {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }
  .memory-col.is-expanded .mem-head {
    display: flex;
  }
  .mem-label {
    font-size: 12px;
    font-family: sans-serif;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(233, 241, 255, 0.68);
    margin-bottom: 14px;
  }
  .mem-head .mem-label {
    margin-bottom: 0;
  }
  .mem-toggle,
  .mem-reopen {
    border: 1px solid rgba(248, 251, 255, 0.22);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    color: rgba(244, 248, 255, 0.82);
    font-size: 12px;
    font-family: sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
  }
  .mem-toggle {
    padding: 8px 12px;
    flex-shrink: 0;
  }
  .mem-reopen {
    position: absolute;
    bottom: 32px;
    right: 32px;
    z-index: 4;
    padding: 11px 16px;
    display: none;
    backdrop-filter: blur(18px);
    box-shadow: 0 18px 42px rgba(0, 0, 0, 0.2);
  }
  .mem-reopen.show {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .mem-toggle:hover,
  .mem-reopen:hover {
    border-color: rgba(248, 251, 255, 0.5);
    color: #f8fbff;
    transform: translateY(-1px);
  }
  .mem-list {
    display: none;
    flex-direction: column;
    gap: 0;
    margin-top: 14px;
  }
  .memory-col.is-expanded .mem-list {
    display: flex;
  }
  .mem-item {
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    cursor: pointer;
    transition: transform 0.18s ease, border-color 0.18s ease;
  }
  .mem-item:hover {
    transform: translateX(-4px);
    border-color: rgba(178, 200, 235, 0.35);
  }
  .mem-item:last-child { border-bottom: none; }
  .mem-text {
    font-size: 16px;
    font-style: italic;
    color: #f7fbff;
    line-height: 1.65;
    margin-bottom: 5px;
  }
  .mem-meta {
    display: flex;
    gap: 10px;
    font-size: 13px;
    font-family: sans-serif;
    color: rgba(228, 236, 248, 0.62);
  }
  .mem-mood { color: #b2c8eb; }
  .add-mem-btn {
    display: none;
  }
  .memory-col.is-expanded .add-mem-btn {
    display: block;
    margin-top: 18px;
    width: 100%;
    padding: 10px;
    border: 1px solid rgba(248, 251, 255, 0.28);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    font-size: 13px;
    font-family: sans-serif;
    color: #f8fbff;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
  }
  .add-mem-btn:hover { border-color: rgba(248, 251, 255, 0.72); color: #f8fbff; }

  .gallery-section {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
    position: relative;
    min-height: 100vh;
  }
  .gallery-header {
    position: absolute;
    left: 40px;
    bottom: 92px;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 0;
    max-width: 420px;
  }
  .gallery-label {
    font-size: 10px;
    font-family: sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(232, 240, 252, 0.74);
  }
  .gallery-subtitle {
    font-size: 12px;
    font-family: sans-serif;
    color: rgba(232, 240, 252, 0.8);
    line-height: 1.5;
    text-shadow: 0 3px 18px rgba(0, 0, 0, 0.35);
  }
  .memory-gallery-shell {
    position: relative;
    height: 100vh;
    border: none;
    border-radius: 0;
    overflow: hidden;
    background:
      radial-gradient(circle at 50% 10%, rgba(49, 76, 119, 0.2), rgba(10, 15, 24, 0.14) 30%, rgba(3, 5, 10, 0.92) 78%),
      linear-gradient(180deg, #0b1220 0%, #04070d 100%);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.04);
  }
  .memory-gallery-shell::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
      linear-gradient(180deg, rgba(188, 214, 255, 0.06), transparent 18%, transparent 74%, rgba(0, 0, 0, 0.36)),
      radial-gradient(circle at 50% 100%, rgba(77, 129, 212, 0.08), transparent 38%);
  }
  #memoryGallery {
    width: 100%;
    height: 100%;
    cursor: grab;
  }
  #memoryGallery.is-dragging {
    cursor: grabbing;
  }
  #memoryGallery canvas {
    display: block;
    width: 100%;
    height: 100%;
  }
  .gallery-fallback {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    text-align: center;
    font-size: 13px;
    font-family: sans-serif;
    color: #91a0b3;
    line-height: 1.6;
  }

  /* â”€â”€ PAGE 2: COMPOSE â”€â”€ */
  #page-compose {
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(3, 6, 12, 0.42);
    backdrop-filter: blur(10px);
    overflow-y: auto;
  }
  #page-compose.active {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 96px 24px 32px;
  }
  .compose-page {
    width: min(720px, 100%);
    margin: 0 auto;
    padding: 28px 28px 26px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 20px;
    background: linear-gradient(180deg, rgba(248, 250, 255, 0.18), rgba(248, 250, 255, 0.1));
    backdrop-filter: blur(24px);
    box-shadow: 0 26px 80px rgba(0, 0, 0, 0.28);
  }
  .compose-back {
    font-size: 12px;
    font-family: sans-serif;
    color: rgba(244, 248, 255, 0.76);
    cursor: pointer;
    margin-bottom: 24px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: color 0.15s;
    border: none;
    background: none;
    padding: 0;
  }
  .compose-back:hover { color: #ffffff; }
  .compose-title {
    font-size: 28px;
    font-weight: 300;
    font-style: italic;
    color: #f8fbff;
    margin-bottom: 6px;
  }
  .compose-sub {
    font-size: 13px;
    font-family: sans-serif;
    color: rgba(236, 243, 255, 0.76);
    line-height: 1.65;
    margin-bottom: 32px;
  }
  .field-label {
    font-size: 10px;
    font-family: sans-serif;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(236, 243, 255, 0.74);
    margin-bottom: 8px;
    display: block;
  }
  .field-group { margin-bottom: 24px; }
  .origin-row { display: flex; gap: 8px; }
  .origin-btn {
    flex: 1;
    padding: 9px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    font-size: 12px;
    font-family: sans-serif;
    color: #eef4ff;
    text-align: center;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.04);
    transition: all 0.15s;
  }
  .origin-btn:hover { border-color: rgba(255,255,255,0.48); color: #ffffff; }
  .origin-btn.sel { border-color: #eef4ff; color: #ffffff; font-weight: 500; background: rgba(255,255,255,0.1); }
  .compose-textarea {
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 10px;
    padding: 14px;
    font-size: 14px;
    font-family: Georgia, serif;
    font-style: italic;
    color: #f8fbff;
    line-height: 1.7;
    min-height: 120px;
    resize: none;
    background: rgba(7, 15, 28, 0.26);
    outline: none;
    transition: border-color 0.15s;
  }
  .compose-textarea:focus { border-color: rgba(248, 251, 255, 0.72); }
  .compose-textarea::placeholder { color: rgba(232,240,252,0.42); }

  /* ai feedback */
  .ai-feedback {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.14);
    border-radius: 10px;
    backdrop-filter: blur(14px);
    padding: 12px 14px;
    margin-bottom: 24px;
    display: none;
  }
  .ai-feedback.show { display: block; }
  .ai-feedback-label {
    font-size: 10px;
    font-family: sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: rgba(236,243,255,0.62);
    margin-bottom: 4px;
  }
  .ai-feedback-text {
    font-size: 13px;
    font-family: sans-serif;
    color: #f1f6ff;
    line-height: 1.55;
  }

  .submit-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
  }
  .anon-note { font-size: 11px; font-family: sans-serif; color: rgba(228,236,248,0.62); }
  .submit-btn {
    padding: 11px 28px;
    background: rgba(255,255,255,0.1);
    color: #f8fbff;
    border: 1px solid rgba(255,255,255,0.24);
    border-radius: 10px;
    font-size: 13px;
    font-family: sans-serif;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
  }
  .submit-btn:hover { background: rgba(255,255,255,0.16); border-color: rgba(255,255,255,0.45); }

  /* success */
  .success-state {
    text-align: center;
    padding: 48px 0;
    display: none;
  }
  .success-state.show { display: block; }
  .success-check {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.34);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
  }
  .success-title {
    font-size: 20px;
    font-weight: 300;
    font-style: italic;
    color: #f8fbff;
    margin-bottom: 8px;
  }
  .success-body {
    font-size: 13px;
    font-family: sans-serif;
    color: rgba(236,243,255,0.74);
    line-height: 1.65;
    margin-bottom: 20px;
  }
  .success-link {
    font-size: 13px;
    font-family: sans-serif;
    color: #f8fbff;
    cursor: pointer;
    text-decoration: underline;
    background: none;
    border: none;
    padding: 0;
  }

  #page-about {
    position: fixed;
    inset: 0;
    z-index: 34;
    background: rgba(3, 6, 12, 0.42);
    backdrop-filter: blur(10px);
    overflow-y: auto;
  }
  #page-about.active {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 96px 24px 32px;
  }
  .about-page {
    width: min(760px, 100%);
    padding: 28px 28px 26px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 20px;
    background: linear-gradient(180deg, rgba(248, 250, 255, 0.18), rgba(248, 250, 255, 0.1));
    backdrop-filter: blur(24px);
    box-shadow: 0 26px 80px rgba(0, 0, 0, 0.28);
  }
  .about-page h2 {
    font-size: 28px;
    font-weight: 300;
    font-style: italic;
    margin-bottom: 16px;
    color: #f8fbff;
  }
  .about-page p {
    font-size: 14px;
    font-family: sans-serif;
    color: rgba(236,243,255,0.8);
    line-height: 1.85;
    margin-bottom: 16px;
  }
  .about-close {
    border: none;
    background: none;
    color: rgba(244,248,255,0.76);
    font-size: 11px;
    font-family: sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    cursor: pointer;
    margin-left: auto;
    display: block;
    margin-bottom: 14px;
  }

@media (max-width: 900px) {
  nav {
    padding: 16px 24px;
  }
  .nav-links {
    gap: 18px;
    flex-wrap: wrap;
    justify-content: flex-end;
  }
  .portrait-header {
    top: 120px;
    left: 24px;
    max-width: calc(100vw - 48px);
  }
  .portrait-title {
    font-size: clamp(40px, 7vw, 52px);
  }
  .portrait-subtitle {
    font-size: 14px;
    line-height: 1.5;
  }
  .gallery-header {
    left: 24px;
    right: 24px;
    bottom: 28px;
    max-width: min(460px, calc(100vw - 48px));
  }
  .memory-col {
      top: auto;
      bottom: 24px;
      right: 24px;
      width: min(360px, calc(100vw - 48px));
      max-height: 42vh;
    }
  .memory-col.is-expanded {
    width: min(360px, calc(100vw - 48px));
  }
  .mem-reopen {
    top: auto;
    right: 24px;
    bottom: 24px;
  }
}

@media (max-width: 720px) {
  nav {
    padding: 14px 16px;
    gap: 10px;
    flex-wrap: wrap;
    align-items: flex-start;
  }
  .logo {
    font-size: 24px;
  }
  .nav-links {
    width: 100%;
    gap: 10px;
    justify-content: stretch;
  }
  .nav-link,
  .nav-btn {
    min-height: 42px;
  }
  .nav-link {
    flex: 1 1 140px;
    text-align: left;
  }
  .nav-btn {
    width: 100%;
  }
  .portrait-layout,
  .gallery-section,
  .memory-gallery-shell {
    min-height: 100svh;
  }
  .portrait-header {
    top: 134px;
    left: 16px;
    right: 16px;
    max-width: none;
  }
  .portrait-title {
    font-size: clamp(30px, 9vw, 40px);
    line-height: 0.98;
  }
  .portrait-subtitle {
    font-size: 12px;
    line-height: 1.45;
  }
  .gallery-header {
    left: 16px;
    right: 16px;
    bottom: 18px;
    gap: 6px;
    max-width: none;
  }
  .gallery-subtitle {
    max-width: 26rem;
    font-size: 11px;
    line-height: 1.45;
  }
  .memory-col {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    width: auto;
    max-height: min(54vh, 460px);
    margin: 0;
    padding: 16px 16px 14px;
    border-radius: 18px;
    z-index: 8;
  }
  .memory-col.is-expanded {
    width: auto;
    max-height: min(68vh, 560px);
  }
  .memory-col.is-hidden {
    display: none;
  }
  .mem-stream-card {
    min-height: 84px;
  }
  .mem-text {
    font-size: 15px;
    line-height: 1.55;
  }
  .mem-meta {
    flex-wrap: wrap;
    row-gap: 4px;
  }
  .mem-reopen {
    position: fixed;
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    margin: 0;
    z-index: 8;
  }
  .submit-row,
  .nav-links,
  .origin-row {
    flex-direction: column;
    align-items: stretch;
  }
  .submit-row {
    gap: 12px;
  }
  .compose-page,
  .about-page {
    border-radius: 16px;
    padding: 20px 16px 18px;
  }
  .compose-title,
  .about-page h2 {
    font-size: 24px;
  }
  .compose-sub,
  .about-page p {
    font-size: 13px;
    line-height: 1.7;
  }
  .compose-textarea {
    min-height: 150px;
    font-size: 16px;
  }
  #page-compose.active,
  #page-about.active {
    padding: calc(82px + env(safe-area-inset-top)) 12px calc(16px + env(safe-area-inset-bottom));
    align-items: flex-start;
  }
}

@media (max-width: 480px) {
  nav {
    padding: 12px 12px 14px;
  }
  .logo {
    font-size: 22px;
  }
  .portrait-header {
    top: 148px;
    left: 12px;
    right: 12px;
  }
  .portrait-title {
    font-size: 28px;
  }
  .gallery-header {
    left: 12px;
    right: 12px;
    bottom: 14px;
  }
  .gallery-subtitle {
    font-size: 10px;
    max-width: 19rem;
  }
  .memory-col {
    left: 8px;
    right: 8px;
    bottom: max(8px, env(safe-area-inset-bottom));
    max-height: min(58vh, 500px);
    padding: 14px 14px 12px;
  }
  .memory-col.is-expanded {
    max-height: min(72vh, 580px);
  }
  .mem-reopen {
    right: 8px;
    bottom: max(8px, env(safe-area-inset-bottom));
  }
  .compose-page,
  .about-page {
    padding: 18px 14px 16px;
  }
  .compose-back,
  .about-close {
    margin-bottom: 18px;
  }
  .success-state {
    padding: 36px 0 12px;
  }
}
