/* Web layout — Tuner for Classical Musicians */
:root {
    --black: #111;
    --white: #fff;
    --gray: #6b7280;
    --gray-light: #9ca3af;
    --border: #e5e7eb;
    --surface: #f8f9fb;
    --panel: #ffffff;
    --blue: #2196f3;
    --red: #e53935;
    --green: #2e7d32;
    --sidebar-w: 220px;
    --topbar-h: 64px;
    --site-header-h: 57px;
    --accent: #111;
    --shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
    --radius: 16px;
    --ad-banner-w: 320px;
    --ad-banner-h: 100px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--surface);
    color: var(--black);
}

.app-page {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    background: var(--surface);
}

.app-page > .site-header .navbar {
    margin-bottom: 0;
}

.app-page > .app-body {
    flex: 1;
    min-height: 0;
}

/* Ad pages use the document as the only scroller (no nested overflow). */
.app-page:has(.has-ad-banner) > .app-body {
    flex: 1 0 auto;
    min-height: auto;
    overflow: visible;
}

.app-body {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    flex: 1;
    min-height: 0;
}

/* Sidebar */
.app-sidebar {
    position: sticky;
    top: 0;
    align-self: start;
    height: calc(100dvh - 56px);
    background: var(--black);
    color: var(--white);
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 8px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.12);
    margin-bottom: 20px;
}

.sidebar-mobile-link {
    text-decoration: none;
    color: var(--white);
    transition: opacity 0.15s;
}

.sidebar-mobile-link:hover {
    opacity: 0.88;
    color: var(--white);
}

.brand-play-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--white);
    color: var(--black);
    display: grid;
    place-items: center;
    font-size: 20px;
    flex-shrink: 0;
}

.brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--white);
    color: var(--black);
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 20px;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.brand-text strong { font-size: 14px; line-height: 1.25; }
.brand-text small { font-size: 11px; color: rgba(255,255,255,0.65); }

.app-side-nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.app-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 10px;
    text-decoration: none;
    color: rgba(255,255,255,0.72);
    font-size: 14px;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}

.app-nav-item img {
    filter: invert(1);
    opacity: 0.7;
}

.app-nav-item:hover {
    background: rgba(255,255,255,0.08);
    color: var(--white);
}

.app-nav-item.active {
    background: var(--white);
    color: var(--black);
}

.app-nav-item.active img {
    filter: none;
    opacity: 1;
}

.sidebar-footer {
    padding-top: 16px;
    border-top: 1px solid rgba(255,255,255,0.12);
}

.sidebar-link {
    color: rgba(255,255,255,0.65);
    text-decoration: none;
    font-size: 13px;
    padding: 8px;
    display: inline-block;
}

.sidebar-link:hover { color: var(--white); }

/* Main shell */
.app-shell {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Ad-banner pages: the document scrolls; the banner stays fixed at the bottom.
   Extra padding keeps controls above the overlay instead of nested inner scroll. */
.app-shell.has-ad-banner {
    position: relative;
    overflow: visible;
}

.app-shell.has-ad-banner .app-main {
    padding-bottom: calc(var(--ad-banner-h) + 40px + env(safe-area-inset-bottom, 0px));
}

.app-shell.has-ad-banner.ad-banner-below-content .app-main {
    padding-bottom: 0;
}

.app-shell.has-ad-banner .app-main:has(.tuner-page) {
    padding-bottom: calc(var(--ad-banner-h) + 36px + env(safe-area-inset-bottom, 0px));
}

.app-shell.has-ad-banner.ad-banner-below-content .app-main:has(.tuner-page) {
    padding-bottom: 0;
}

.app-shell.has-ad-banner .app-main:has(.matching-page) {
    display: block;
    padding: 0;
    padding-bottom: calc(var(--ad-banner-h) + 40px + env(safe-area-inset-bottom, 0px));
}

.app-shell.has-ad-banner.ad-banner-below-content .app-main:has(.matching-page) {
    padding-bottom: 0;
}

.app-topbar {
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 8px 0 16px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.app-topbar-center {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: inline-flex;
    align-items: center;
    gap: 2px;
    max-width: min(56%, 480px);
    pointer-events: none;
    z-index: 0;
}

.app-topbar-center > * {
    pointer-events: auto;
}

.app-topbar-title {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    text-align: center;
}

.app-topbar-settings {
    flex-shrink: 0;
}

.app-topbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 2px;
    margin-left: auto;
    margin-right: 0;
    flex-shrink: 0;
    position: relative;
    z-index: 2;
}

.app-member-topbar[hidden],
.app-member-login[hidden],
.app-member-logout[hidden] {
    display: none !important;
}

.app-member-login {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    color: #2563eb;
    font-weight: 600;
    font-size: 0.95rem;
    padding: 6px 4px;
}

.app-member-login:hover {
    color: #1d4ed8;
    text-decoration: underline;
}

.app-member-topbar {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    padding: 2px;
    border: 0;
    background: transparent;
    flex-shrink: 0;
    line-height: 0;
}

.app-member-topbar:hover {
    opacity: 0.85;
}

.app-member-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background: #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: #4b5563;
}

.app-member-avatar-empty {
    background: #e5e7eb;
}

.app-member-logout {
    display: inline-flex;
    align-items: center;
    min-height: auto;
    padding: 6px 4px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: #2563eb;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
}

.app-member-logout:hover {
    color: #1d4ed8;
    text-decoration: underline;
}

.app-icon-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px;
    cursor: pointer;
}

.app-main {
    flex: 1;
    padding: 28px 32px 40px;
}

.app-main:has(.tuner-page) {
    padding-bottom: 24px;
}

.app-main:has(.profile-page) {
    padding: 0 0 40px;
}

/* Ad banner — fixed to viewport bottom when content fills; sits under frame when short.
   --ad-banner-bottom-lift raises the banner when the site footer scrolls into view. */
.ad-banner-slot {
    --ad-banner-bottom-lift: 0px;
    position: fixed;
    bottom: max(10px, calc(6px + var(--ad-banner-bottom-lift) + env(safe-area-inset-bottom, 0px)));
    left: var(--sidebar-w);
    right: 0;
    height: 0;
    overflow: visible;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    z-index: 200;
    pointer-events: none;
    padding: 0 16px;
    margin: 0;
    background: transparent;
    border: none;
    box-sizing: border-box;
}

.app-shell > .ad-banner-slot {
    left: 0;
    right: 0;
}

/* In flow — sits directly under .app-main when content is shorter than the viewport */
.ad-banner-slot.is-below-content {
    position: static;
    left: auto;
    right: auto;
    bottom: auto;
    height: auto;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    padding: 12px 16px 16px;
    pointer-events: none;
}

.ad-banner-inner {
    width: min(var(--ad-banner-w), 100%);
    max-width: 100%;
    aspect-ratio: 320 / 100;
    height: auto;
    pointer-events: auto;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.16), 0 4px 10px rgba(15, 23, 42, 0.08);
    flex-shrink: 1;
}

.ad-banner-loading {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    background: var(--panel);
    border: 1px dashed var(--border);
    border-radius: 10px;
}

.ad-banner-loading::after {
    content: '';
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-top-color: var(--gray);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.ad-banner-placeholder {
    width: 100%;
    height: 100%;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.ad-banner-frame,
.ad-banner-link {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 10px;
    overflow: hidden;
}

.ad-banner-link {
    text-decoration: none;
}

.ad-banner-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: fill;
}

.ad-banner-country {
    position: absolute;
    top: 6px;
    left: 6px;
    padding: 3px 6px;
    font-size: 11px;
    font-weight: 700;
    color: var(--white);
    background: rgba(0, 0, 0, 0.6);
    border-radius: 4px;
    line-height: 1.2;
}

/* Tuner two-panel layout (matches metronome web-page) */
.tuner-page .panel {
    padding: 20px;
}

.tuner-controls-panel {
    align-items: center;
    gap: 16px;
    justify-content: flex-start;
}

.tuner-page .instrument-display {
    flex: 1;
    min-height: 200px;
    padding: 12px 40px 12px 12px;
}

.tuner-page .detection-row {
    width: 100%;
    max-width: 360px;
    justify-content: center;
}

.web-page {
    display: grid;
    grid-template-columns: minmax(320px, 0.95fr) minmax(360px, 1.1fr);
    gap: 24px;
    align-items: stretch;
    max-width: 1280px;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    height: 100%;
    box-sizing: border-box;
}

.panel-visual {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: auto;
}

.panel-controls {
    display: flex;
    flex-direction: column;
    gap: 28px;
    justify-content: flex-start;
    min-height: auto;
}

.metronome-page .panel-controls {
    justify-content: center;
}

/* Instrument / tempo header */
.instrument-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.nav-arrow {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    font-size: 28px;
    color: var(--gray);
    cursor: pointer;
    line-height: 1;
}

.nav-arrow:hover { background: #eee; color: var(--black); }

.instrument-title-wrap { text-align: center; flex: 1; }

.instrument-name {
    font-size: 28px;
    font-weight: 700;
    margin: 0;
    text-transform: capitalize;
}

.swipe-hint {
    font-size: 13px;
    color: var(--gray-light);
    margin: 4px 0 0;
}

.instrument-display,
.metronome-display {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    min-height: 280px;
    flex: 1;
    background: #fff;
    border-radius: 12px;
    padding: 12px 40px 12px 12px;
}

.instrument-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-width: 0;
}

.instrument-image-wrap {
    position: relative;
    width: min(100%, 280px);
    height: 260px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.instrument-image,
.metronome-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}

.french-horn-c {
    position: absolute;
    bottom: 8px;
    font-size: 14px;
    font-weight: 700;
    color: #000;
}

.volume-bar-wrap {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.volume-label {
    font-size: 11px;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.volume-bar {
    writing-mode: vertical-lr;
    direction: rtl;
    width: 28px;
    height: 180px;
    accent-color: var(--black);
}

.string-labels {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    width: 100%;
    margin-top: 4px;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
}

.string-labels.is-hidden,
.string-labels[hidden] {
    display: none !important;
}

/* Pitch controls */
.pitch-controls {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 16px;
    width: 100%;
    max-width: 360px;
}

.pitch-dropdown-wrap { flex: 1; max-width: 240px; }

.mic-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
}

.mic-hint {
    font-size: 12px;
    color: var(--gray);
}

.tuner-page .piano-section {
    width: 100%;
    max-width: 420px;
    margin-top: 4px;
}

.field-label {
    display: block;
    font-size: 13px;
    color: var(--gray);
    margin-bottom: 6px;
    font-weight: 500;
}

.pitch-select,
.text-input,
.bpm-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 16px;
    background: var(--white);
}

.play-btn-wrap {
    position: relative;
    flex-shrink: 0;
    width: 72px;
    height: 72px;
}

.play-btn {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: none;
    background: var(--black);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: 0 8px 20px rgba(0,0,0,0.18);
}

.play-btn .play-icon { filter: invert(1); }

/* Overlay to the right of play — never shifts layout */
.countdown {
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    font-weight: 700;
    color: var(--gray);
    white-space: nowrap;
    pointer-events: none;
    line-height: 1;
}

.countdown[hidden] {
    display: none !important;
}

/* Detection row — fixed card sizes so content never resizes frames */
.detection-row {
    display: flex;
    align-items: stretch;
    gap: 0;
    flex-wrap: nowrap;
    border: 1px solid var(--black);
    border-radius: 10px;
    overflow: hidden;
    width: 320px;
    max-width: 100%;
    flex-shrink: 0;
}

.detection-row.is-hidden,
.detection-row[hidden] {
    display: none !important;
}

.detection-card {
    border: none;
    border-right: 1px solid var(--black);
    padding: 8px 4px;
    height: 44px;
    min-height: 44px;
    max-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    background: var(--white);
    transition: background 0.15s, color 0.15s;
    overflow: hidden;
    white-space: nowrap;
    box-sizing: border-box;
    flex: 0 0 auto;
}

.detection-card:last-child {
    border-right: none;
}

.note-card {
    width: 48px;
    min-width: 48px;
    max-width: 48px;
    font-size: 16px;
    font-weight: 700;
    border-radius: 10px 0 0 10px;
}
.diff-card {
    width: 64px;
    min-width: 64px;
    max-width: 64px;
    font-size: 11px;
    justify-content: flex-end;
    padding-right: 6px;
}
.diff-card.sharp {
    justify-content: flex-start;
    padding-left: 6px;
    padding-right: 4px;
}
.hz-card {
    width: 144px;
    min-width: 144px;
    max-width: 144px;
    color: var(--gray);
    justify-content: center;
    font-size: 12px;
    padding-left: 4px;
    padding-right: 4px;
    text-align: center;
}

.hz-card.mic-off-clickable {
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.hz-card.mic-off-clickable:hover {
    background: #f3f4f6;
}
.diff-card.sharp:last-child {
    border-radius: 0 10px 10px 0;
}

.mic-toggle {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid var(--black);
    background: var(--black);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
}

.mic-toggle.open {
    box-shadow: 0 0 0 3px rgba(0,0,0,0.12);
}

.mic-toggle.active .mic-dot { display: none; }
.mic-toggle.active::after {
    content: "×";
    color: var(--white);
    font-size: 16px;
    line-height: 1;
}

.mic-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--white);
}

/* Piano */
.piano-section { margin-top: 8px; }

.octave-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.octave-label {
    font-size: 20px;
    font-weight: 700;
    min-width: 56px;
}

.octave-btn {
    width: 40px;
    height: 40px;
    border: 1px solid var(--black);
    background: var(--white);
    font-size: 22px;
    font-weight: 700;
    cursor: pointer;
    border-radius: 8px;
}

.piano-wrap {
    position: relative;
    width: min(100%, 420px);
}

.piano-keyboard {
    position: relative;
    display: flex;
    width: 100%;
    height: 96px;
    border: 1px solid var(--black);
    border-radius: 4px;
    overflow: visible;
    background: #111;
}

.piano-keyboard .key {
    margin: 0;
    padding: 0;
    cursor: pointer;
    border: none;
    appearance: none;
}

.piano-keyboard .key.white {
    flex: 1 1 0;
    height: 100%;
    background: #fff;
    border-right: 1px solid #111;
    border-radius: 0 0 3px 3px;
    z-index: 1;
}

.piano-keyboard .key.white:last-of-type {
    border-right: none;
}

.piano-keyboard .key.white:active {
    background: #e8e8e8;
}

.piano-keyboard .key.black {
    position: absolute;
    top: 0;
    width: 9.5%;
    height: 58%;
    background: #111;
    border: 1px solid #000;
    border-radius: 0 0 3px 3px;
    z-index: 2;
    transform: translateX(-50%);
}

.piano-keyboard .key.black:active {
    background: #333;
}

.piano-arrow {
    position: absolute;
    top: -14px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 12px solid #c00;
    transition: left 0.1s;
    pointer-events: none;
}

.piano-arrow[hidden] {
    display: none !important;
}

/* Metronome */
.bpm-display-wrap { text-align: center; }

.bpm-display {
    font-size: 96px;
    font-weight: 700;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    color: var(--black);
}

.metronome-display {
    background: #fff;
}

.metronome-image-wrap { margin: 8px 0; }
.metronome-image { width: 200px; height: 200px; }

.metronome-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 28px;
}

.bpm-adjust-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 1px solid var(--black);
    background: var(--white);
    font-size: 32px;
    font-weight: 700;
    cursor: pointer;
    line-height: 1;
}

.metronome-play {
    width: 80px;
    height: 80px;
}

.metronome-play.playing { background: var(--black); }
.metronome-play.playing .play-icon { filter: invert(1); }
.metronome-play:not(.playing) {
    background: var(--white);
    border: 2px solid var(--black);
}
.metronome-play:not(.playing) .play-icon { filter: none; }

.tempo-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 10px;
}

.tempo-btn {
    padding: 14px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.tempo-btn.active {
    background: var(--black);
    color: var(--white);
    border-color: var(--black);
}

.beat-section {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--surface);
    border-radius: 12px;
}

.beat-indicators {
    flex: 1;
    display: flex;
    justify-content: space-evenly;
    gap: 8px;
    flex-wrap: wrap;
}

.beat-dot {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--black);
    position: relative;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--white);
}

.beat-dot.strong::before {
    content: "";
    width: 45%;
    height: 45%;
    border-radius: 50%;
    background: var(--black);
}

.beat-dot.active::after {
    content: "";
    position: absolute;
    inset: 10%;
    border-radius: 50%;
    background: var(--green);
}

.beat-dot.strong.active::after { background: var(--red); }
.beat-dot.muted { color: var(--gray); font-size: 16px; font-weight: 700; }

.bar-count {
    width: 64px;
    text-align: center;
    font-size: 13px;
}

.bar-label { display: block; color: var(--gray); }
.bar-value { font-size: 24px; font-weight: 700; }

/* Dialogs */
.app-dialog {
    border: none;
    border-radius: 12px;
    padding: 0;
    max-width: 92vw;
    width: 420px;
}

.app-dialog::backdrop { background: rgba(0,0,0,0.4); }

.dialog-content {
    padding: 24px;
    max-height: 75vh;
    overflow-y: auto;
}

.dialog-content h2 {
    margin: 0 0 16px;
    font-size: 22px;
}

.dialog-message {
    margin: 0 0 16px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--black);
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}

.btn-primary, .btn-secondary {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    border: none;
}

.btn-primary { background: var(--black); color: var(--white); }
.btn-secondary { background: transparent; color: var(--black); }

.duration-control {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 8px 0 16px;
}

.duration-value {
    font-size: 28px;
    font-weight: 700;
    text-align: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 24px;
    margin: 4px 0;
}

.duration-value small {
    display: block;
    font-size: 12px;
    color: var(--gray);
    font-weight: 400;
}

.duration-arrow {
    background: none;
    border: none;
    font-size: 16px;
    color: var(--gray-light);
    cursor: pointer;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 12px 0;
}

/* Login */
.login-page {
    max-width: 440px;
    margin: 0 auto;
    padding: 24px 0 40px;
}

.login-title {
    text-align: center;
    font-size: 32px;
    margin-bottom: 24px;
}

.login-message {
    background: #fff3cd;
    color: #856404;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 16px;
    text-align: center;
    font-size: 14px;
}

.login-card {
    background: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    padding: 24px;
}

.login-card h3 { margin: 0 0 16px; font-size: 18px; }
.login-card .text-input { margin-bottom: 12px; }

.password-wrap {
    position: relative;
    margin-bottom: 12px;
}

.password-toggle {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    opacity: 0.5;
}

.login-btn { width: 100%; margin-top: 8px; padding: 14px; font-size: 16px; }

.login-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
    color: var(--gray);
    font-size: 14px;
}

.login-divider::before,
.login-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

.google-signin-container { display: flex; justify-content: center; }

.google-hint {
    font-size: 12px;
    color: var(--gray);
    text-align: center;
    margin-top: 16px;
}

.login-feedback {
    margin-top: 12px;
    text-align: center;
    font-size: 14px;
}

.login-feedback.error { color: var(--red); }
.login-feedback.success { color: var(--green); }

.login-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 24px;
    flex-wrap: wrap;
    gap: 8px;
}

.footer-link {
    color: var(--black);
    font-size: 14px;
    text-decoration: none;
}

.login-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 200;
    color: var(--white);
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: var(--white);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Matching: stack before the Discover frame gets skinny */
@media (max-width: 1180px) {
    .matching-layout.web-page {
        display: flex;
        flex-direction: column;
        grid-template-columns: none;
        gap: 16px;
        max-width: none;
    }

    .matching-side-col,
    .matching-content-col {
        width: 100%;
        min-width: 0;
    }

    .matching-side-col {
        flex: 0 0 auto;
    }

    .matching-tabs {
        width: 100%;
        max-width: 100%;
    }

    .matching-tab {
        flex: 1 1 0;
        text-align: center;
        min-width: 0;
    }

    .matching-content-col {
        min-height: 0;
        flex: 0 1 auto;
    }

    .matching-content-col .matching-swipe-card {
        width: 100%;
        max-width: none;
    }
}

/* Responsive: tablet / mobile */
@media (max-width: 960px) {
    .app-body {
        grid-template-columns: 1fr;
    }

    .app-sidebar {
        position: sticky;
        top: 0;
        width: 100%;
        max-width: 100%;
        height: auto;
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        justify-content: space-evenly;
        gap: 0;
        padding: 10px 8px;
        z-index: 60;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        scrollbar-width: none;
        cursor: grab;
        touch-action: pan-x;
    }

    .app-sidebar::-webkit-scrollbar {
        display: none;
    }

    .app-sidebar.is-dragging {
        cursor: grabbing;
        user-select: none;
    }

    .app-sidebar.is-dragging a {
        pointer-events: none;
    }

    /* Flatten nav so brand + each menu item share space evenly */
    .app-side-nav {
        display: contents;
    }

    .sidebar-brand {
        border: none;
        margin: 0;
        padding: 0 6px;
        flex: 1 0 auto;
        justify-content: center;
        min-width: max-content;
    }
    .sidebar-mobile-link .brand-text {
        display: flex;
        align-items: center;
    }
    .sidebar-mobile-link .brand-text strong { font-size: 12px; white-space: nowrap; }

    .app-nav-item {
        flex: 1 0 auto;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 4px;
        padding: 8px 10px;
        font-size: 11px;
        white-space: nowrap;
        min-width: max-content;
        text-align: center;
    }

    .sidebar-footer { display: none; }

    .web-page {
        grid-template-columns: 1fr;
    }

    .matching-layout.web-page {
        display: flex;
        flex-direction: column;
        grid-template-columns: none;
        gap: 12px;
        max-width: none;
    }

    .matching-content-col,
    .matching-side-col {
        background: transparent;
        border: 0;
        box-shadow: none;
        padding: 0;
        overflow: visible;
        border-radius: 0;
        height: auto;
        min-height: 0;
    }

    .matching-content-col {
        min-height: 0;
    }

    .matching-content-col .matching-swipe-card {
        min-height: 0;
    }

    .matching-content-col:not(:has(.matching-panel.active)) {
        display: none;
    }

    /* Side col is intro + tabs only — always keep visible on mobile */
    .matching-side-col {
        display: flex !important;
    }

    .panel-visual,
    .panel-controls {
        min-height: auto;
    }

    .app-main { padding: 16px; }
    .app-shell.has-ad-banner .app-main:has(.matching-page) {
        padding: 0;
        padding-bottom: calc(var(--ad-banner-h) + 40px + env(safe-area-inset-bottom, 0px));
    }
    .app-shell.has-ad-banner.ad-banner-below-content .app-main:has(.matching-page) {
        padding-bottom: 0;
    }
    .app-main:has(.profile-page) {
        padding: 0 0 24px;
    }
    .profile-layout.web-page:has(#match-profile-section[hidden]) {
        max-width: none;
    }
    .ad-banner-slot { left: 0; }
    .app-topbar {
        position: relative;
        top: auto;
        padding: 0 6px 0 12px;
    }
    .app-topbar-title { font-size: 18px; }
}

@media (max-width: 560px) {
    .pitch-controls { flex-wrap: wrap; }
    .detection-row { justify-content: center; }
    .bpm-display { font-size: 64px; }
    .instrument-image-wrap { height: 220px; }
}

/* Practice Log */
.practice-log-page {
    padding: 20px;
    max-width: 1100px;
    width: 100%;
    box-sizing: border-box;
}

.practice-log-heading {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.practice-log-subtitle {
    color: #6b7280;
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 1.5rem;
}

.practice-log-storage {
    margin-top: -0.75rem;
    margin-bottom: 1.25rem;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    padding: 12px 14px;
}

.practice-log-storage-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    color: #111827;
    cursor: pointer;
}

.practice-log-storage-label input {
    margin-top: 3px;
}

.practice-log-storage-help {
    margin: 0.5rem 0 0 1.65rem;
    color: #6b7280;
    font-size: 0.82rem;
    line-height: 1.45;
}

.practice-log-storage-message {
    margin: 0.5rem 0 0 1.65rem;
    font-size: 0.85rem;
    line-height: 1.4;
}

.practice-log-storage-message.is-error {
    color: #b91c1c;
}

.practice-log-syncing {
    margin-top: 0.75rem;
    padding: 0;
}

.practice-log-card {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    padding: 1.25rem;
    border-radius: 4px;
}

.practice-log-login-btn {
    display: inline-block;
    margin-top: 1rem;
    text-decoration: none;
    text-align: center;
}

.practice-log-status {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 2rem 0;
    color: #6b7280;
}

.practice-log-status .spinner {
    border-color: rgba(0,0,0,0.15);
    border-top-color: #111;
}

.practice-log-error {
    color: #b91c1c;
    font-size: 0.9rem;
}

.practice-log-totals {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    padding: 14px 16px;
    margin-bottom: 1rem;
}

.practice-log-totals-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.practice-log-year-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 3.25em;
    padding: 2px 8px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    background: #eef2ff;
    color: #3730a3;
    font-size: 0.8rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
}

.practice-log-totals-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: #6b7280;
}

.practice-log-totals-value {
    font-size: 1.05rem;
    font-weight: 600;
    color: #111827;
}

.practice-log-totals-level {
    margin-top: 0.35rem;
    font-size: 0.9rem;
    color: #374151;
}

.practice-log-totals-level .level-title {
    font-weight: 600;
}

.practice-log-totals-level .level-hint {
    display: block;
    margin-top: 0.15rem;
    font-size: 0.8rem;
    color: #6b7280;
}

.practice-log-view-years {
    display: inline-block;
    margin-top: 0.65rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: #2563eb;
    text-decoration: none;
}

.practice-log-view-years:hover {
    text-decoration: underline;
}

.practice-log-years-toolbar {
    margin-bottom: 1rem;
}

.practice-log-years-heading {
    margin: 0.5rem 0 0;
    font-size: 1.05rem;
    font-weight: 600;
    color: #111827;
}

.practice-log-levels-guide {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    padding: 12px 14px;
    margin-bottom: 1rem;
}

.practice-log-levels-guide-header {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin-bottom: 0.4rem;
}

.practice-log-info-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 999px;
    background: #e0e7ff;
    color: #3730a3;
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1;
}

.practice-log-levels-title {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: #111827;
}

.practice-log-levels-notice {
    margin: 0 0 0.75rem;
    font-size: 0.8rem;
    color: #6b7280;
    line-height: 1.4;
}

.practice-log-levels-table-wrap {
    overflow-x: auto;
}

.practice-log-levels-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.practice-log-levels-table th,
.practice-log-levels-table td {
    border: 1px solid #e5e7eb;
    padding: 0.4rem 0.5rem;
    text-align: left;
    white-space: nowrap;
}

.practice-log-levels-table th {
    background: #f3f4f6;
    font-weight: 600;
    color: #374151;
}

.practice-log-levels-table td {
    color: #111827;
}

.practice-log-years-list {
    display: grid;
    gap: 0.75rem;
}

.practice-log-year-card {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    padding: 12px 14px;
}

.practice-log-year-card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.practice-log-year-card-stats {
    font-size: 0.95rem;
    font-weight: 600;
    color: #111827;
}

.practice-log-year-card-level {
    margin-top: 0.25rem;
    font-size: 0.85rem;
    color: #374151;
}

.practice-log-year-card-hint {
    margin-top: 0.15rem;
    font-size: 0.8rem;
    color: #6b7280;
}

.practice-log-legend {
    display: flex;
    gap: 1.25rem;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    color: #6b7280;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.legend-item::before {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 3px;
    background: currentColor;
}

.legend-tuner { color: #4a7dff; }
.legend-metronome { color: #1db8a6; }

.practice-log-weeks {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
    gap: 1.25rem;
    align-items: stretch;
}

@media (max-width: 640px) {
    .practice-log-weeks {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.75rem;
    }

    .practice-log-week-block {
        padding: 0.75rem;
    }

    .practice-log-week-header {
        flex-direction: column;
        gap: 0.25rem;
        margin-bottom: 0.5rem;
    }

    .practice-log-chart {
        gap: 0.25rem;
        padding: 0.55rem 0.35rem 0.65rem;
    }

    .practice-log-chart-bars {
        height: 72px;
        gap: 2px;
    }
}

.practice-log-week-block {
    margin: 0;
    padding: 1rem 1rem 1.1rem;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #fff;
    min-width: 0;
}

.practice-log-week-block:last-child {
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 0;
    padding-bottom: 1.1rem;
}

.practice-log-week-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.practice-log-chart {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.5rem;
    align-items: end;
    min-height: 0;
    padding: 0.75rem 0.5rem 0.85rem;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid #e8edf2;
    border-radius: 8px;
    overflow: visible;
    box-sizing: border-box;
}

.practice-log-chart-day {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    min-width: 0;
    min-height: 0;
    cursor: default;
    border-radius: 6px;
    outline: none;
    transition: background 0.15s ease;
    overflow: visible;
}

.practice-log-chart-day:hover,
.practice-log-chart-day:focus-visible {
    background: rgba(15, 23, 42, 0.04);
}

.practice-log-chart-bars {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 4px;
    width: 100%;
    height: 100px;
}

.practice-log-chart-bar {
    width: 40%;
    min-height: 2px;
    border-radius: 5px 5px 2px 2px;
    transition: height 0.2s ease, filter 0.15s ease, transform 0.15s ease;
}

.practice-log-chart-day:hover .practice-log-chart-bar,
.practice-log-chart-day:focus-visible .practice-log-chart-bar {
    filter: brightness(1.06);
}

.practice-log-chart-bar-tuner {
    background: linear-gradient(180deg, #7aa2ff 0%, #4a7dff 55%, #3b6ef0 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.practice-log-chart-bar-metronome {
    background: linear-gradient(180deg, #5ee0d0 0%, #1db8a6 55%, #149e8e 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.practice-log-chart-day-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #374151;
    line-height: 1.2;
    white-space: nowrap;
}

.practice-log-chart-day-values {
    font-size: 0.65rem;
    color: #9ca3af;
    line-height: 1.2;
    white-space: nowrap;
}

.practice-log-tooltip {
    position: fixed;
    z-index: 1000;
    min-width: 180px;
    max-width: 260px;
    padding: 0.65rem 0.8rem;
    background: #111;
    color: #fff;
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    font-size: 0.8rem;
    line-height: 1.4;
    pointer-events: none;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.12s ease, transform 0.12s ease;
}

.practice-log-tooltip.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.practice-log-tooltip-date {
    font-weight: 600;
    margin-bottom: 0.45rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.practice-log-tooltip-row {
    display: grid;
    grid-template-columns: 10px 1fr auto;
    gap: 0.45rem;
    align-items: center;
    margin-top: 0.35rem;
}

.practice-log-tooltip-row strong {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.practice-log-tooltip-swatch {
    width: 8px;
    height: 8px;
    border-radius: 2px;
    background: currentColor;
}

.practice-log-week {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 0;
    border-bottom: 1px solid #e5e7eb;
}

.practice-log-week-label {
    font-size: 0.9rem;
    font-weight: 500;
}

.practice-log-week-stats {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    font-size: 0.85rem;
}

.practice-log-stat-tuner { color: #4a7dff; }
.practice-log-stat-metronome { color: #1db8a6; }

/* Matching — left: Find a Music Partner + lists | right: Discover card (Practice Log scroll) */
.matching-page {
    padding: 20px;
    max-width: 1280px;
    width: 100%;
    box-sizing: border-box;
}

.matching-layout.web-page {
    width: 100%;
    max-width: none;
    align-items: start;
    /* Left: intro + tabs; right: active content frame (Discover / Matches / Preferences / Blocked) */
    grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
    gap: 24px;
}

.matching-side-col,
.matching-content-col {
    min-height: 0;
    min-width: 0;
    height: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow: visible;
}

.matching-content-col {
    width: 100%;
}

.matching-content-col #panel-discover.matching-panel.active,
.matching-content-col #discover-content,
.matching-content-col .matching-swipe-card {
    flex: 0 1 auto;
    min-height: 0;
    min-width: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
}

.matching-content-col .matching-swipe-card {
    overflow: visible;
}

.matching-intro {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 0.35rem;
}

.matching-heading {
    font-size: 1.0625rem; /* 17sp */
    font-weight: 600;
    margin: 0;
    line-height: 1.25;
}

.matching-subtitle {
    color: #6b7280;
    font-size: 0.8125rem; /* 13sp */
    line-height: 1.3;
    margin: 0;
}

.matching-hint {
    color: #6b7280;
    font-size: 0.85rem;
    line-height: 1.4;
    margin-bottom: 0.65rem;
}

.matching-card {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    padding: 1.25rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.matching-notice p { margin-bottom: 0.75rem; }
.matching-notice p:last-of-type { margin-bottom: 1rem; }

.matching-missing-list {
    margin: 0 0 1rem 1.1rem;
    padding: 0;
    color: #374151;
    font-size: 0.9rem;
}

.matching-missing-list li { margin-bottom: 0.35rem; }

.matching-profile-required-banner {
    margin-bottom: 1.25rem;
    padding: 1rem 1.1rem;
    border: 1px solid #fcd34d;
    border-radius: 4px;
    background: #fffbeb;
    color: #92400e;
    font-size: 0.9rem;
}

.matching-profile-required-banner p { margin: 0 0 0.5rem; }

.matching-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.matching-section-header > span:first-child,
.matching-section-title-row > span:first-child {
    font-weight: 600;
    font-size: 0.9rem;
}

.matching-section-title-row {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 0;
}

.matching-add-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: #2563eb;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
}

.matching-add-icon-btn:hover {
    background: #eff6ff;
    color: #1d4ed8;
}

.matching-section-title-col {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.matching-section-title-col > span:first-child {
    font-weight: 600;
    font-size: 0.9rem;
}

.matching-section-title-col .matching-field-hint {
    margin: 0;
}

.matching-add-text-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0;
    padding: 0.2rem 0.5rem;
    border: 0;
    background: transparent;
    color: #2563eb;
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.matching-add-text-btn:hover {
    color: #1d4ed8;
}

.matching-add-text-btn[hidden] {
    display: none;
}

.matching-video-card {
    background: #fff;
    border-radius: 12px;
}

.matching-video-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.65rem;
}

.matching-video-card-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #1a1a1a;
}

.matching-video-card-head .matching-icon-btn {
    align-self: center;
    margin: 0;
}

.matching-video-url-wrap {
    position: relative;
}

.matching-video-url-wrap > i {
    position: absolute;
    left: 0.7rem;
    top: 50%;
    transform: translateY(-50%);
    color: #6b7280;
    pointer-events: none;
}

.matching-video-url-wrap .video-url {
    padding-left: 2rem;
}

.matching-video-or {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin: 0.75rem 0;
    color: #6b7280;
    font-size: 0.75rem;
}

.matching-video-or::before,
.matching-video-or::after {
    content: "";
    flex: 1;
    height: 1px;
    background: #e5e7eb;
}

.matching-video-upload-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    min-height: 40px;
    padding: 0 0.85rem;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    background: #fff;
    color: #1a1a1a;
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.matching-video-upload-btn:hover:not(:disabled) {
    background: #f8fafc;
}

.matching-video-upload-btn:disabled {
    opacity: 0.6;
    cursor: default;
}

.matching-video-upload-status {
    margin: 0.5rem 0 0;
    font-size: 0.75rem;
    color: #6b7280;
}

.matching-video-upload-status.is-error {
    color: #b91c1c;
}

.profile-level-info-dialog {
    max-width: 420px;
}

.profile-level-info-list {
    max-height: 360px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin: 0 0 1rem;
}

.profile-level-info-item strong {
    display: block;
    font-size: 0.9rem;
    color: #1a1a1a;
}

.profile-level-info-item p {
    margin: 0.15rem 0 0;
    font-size: 0.8rem;
    color: #4b5563;
    line-height: 1.4;
}

.matching-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: #9ca3af;
    font-size: 1.05rem;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
    align-self: end;
    margin-bottom: 0.15rem;
}

.matching-icon-btn:hover {
    background: #f3f4f6;
    color: #6b7280;
}

.matching-icon-btn-delete:hover {
    background: #fef2f2;
    color: #dc2626;
}

.matching-video-title-row {
    display: flex;
    align-items: flex-end;
    gap: 0.35rem;
}

.matching-field-grow {
    flex: 1;
    min-width: 0;
    margin-bottom: 0.75rem;
}

.matching-requirement-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    white-space: nowrap;
}

.matching-requirement-badge.missing {
    color: #b91c1c;
    background: #fee2e2;
}

.matching-profile-hero {
    margin-bottom: 1.5rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid #e5e7eb;
}

.matching-profile-photo-box {
    width: 100%;
    max-width: 280px;
    aspect-ratio: 1 / 1;
    margin: 0 auto 0.75rem;
    border: 2px solid #e5e7eb;
    border-radius: 4px;
    background: #f9fafb;
    overflow: hidden;
    position: relative;
    cursor: pointer;
}

.matching-profile-photo {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.matching-profile-photo-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    height: 100%;
    color: #9ca3af;
    font-size: 0.9rem;
    text-align: center;
    padding: 1rem;
}

.matching-profile-photo-placeholder-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    border: 2px dashed #d1d5db;
    border-radius: 4px;
    font-size: 1.75rem;
    line-height: 1;
    color: #9ca3af;
}

.matching-profile-upload-btn {
    display: block;
    width: 100%;
    max-width: 280px;
    margin: 0 auto;
    text-align: center;
    padding: 0.65rem 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    background: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.matching-profile-upload-btn:hover {
    background: #f9fafb;
}

.matching-required-section {
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid #f3f4f6;
}

.matching-login-btn {
    display: inline-block;
    text-decoration: none;
    text-align: center;
}

.matching-status {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 2rem 0;
    color: #6b7280;
}

.matching-error { color: #b91c1c; font-size: 0.9rem; }

.matching-tabs {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem;
    width: 100%;
    max-width: 100%;
    margin: 0 0 0.35rem;
    padding: 0.25rem;
    overflow: visible;
    flex-shrink: 0;
    background: #e8eaed;
    border-radius: 8px;
    box-sizing: border-box;
}

.matching-tabs::-webkit-scrollbar {
    display: none;
}

.matching-tab {
    padding: 0.45rem 0.4rem;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #4b5563;
    font-size: 0.8125rem; /* 13sp */
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    flex: 1 1 0;
    text-align: center;
    line-height: 1.25;
    min-width: 0;
}

.matching-tab.active {
    background: #fff;
    color: #111827;
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
}

.matching-tab-count {
    display: inline-block;
    margin-left: 0.35rem;
    padding: 0.05rem 0.4rem;
    border-radius: 999px;
    background: #111827;
    color: #fff;
    font-size: 0.6875rem;
    font-weight: 600;
    line-height: 1.35;
    vertical-align: middle;
}

.matching-message-storage {
    margin: 0 0 1rem;
    padding: 0.75rem 0.9rem;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #f9fafb;
}

.matching-message-storage-row {
    display: flex;
    gap: 0.65rem;
    align-items: flex-start;
    font-size: 0.875rem;
    color: #111827;
}

.matching-message-storage-hint {
    display: block;
    margin-top: 0.25rem;
}

.matching-chat {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-height: 360px;
}

.matching-chat-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.matching-chat-peer {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    text-align: left;
}

.matching-chat-peer .matching-card-avatar {
    width: 2rem;
    height: 2rem;
    flex-shrink: 0;
}

.matching-chat-title {
    margin: 0;
    font-size: 1rem;
}

.matching-peer-modal-dialog {
    max-width: 520px;
}

.matching-peer-profile {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.matching-chat-thread {
    flex: 1;
    min-height: 260px;
    max-height: 420px;
    overflow: auto;
    padding: 0.75rem;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.matching-chat-bubble {
    max-width: 75%;
    padding: 0.55rem 0.75rem;
    border-radius: 12px;
    font-size: 0.875rem;
    line-height: 1.35;
    white-space: pre-wrap;
    word-break: break-word;
}

.matching-chat-bubble.mine {
    align-self: flex-end;
    background: #2563eb;
    color: #fff;
}

.matching-chat-bubble.theirs {
    align-self: flex-start;
    background: #fff;
    border: 1px solid #e5e7eb;
    color: #111827;
}

.matching-chat-compose {
    display: flex;
    gap: 0.5rem;
}

.matching-chat-compose input {
    flex: 1;
    padding: 0.55rem 0.75rem;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
}

.matching-chat-compose input:disabled {
    background: #f3f4f6;
    color: #9ca3af;
}

.matching-chat-nosend {
    margin: 0;
    padding: 0 0.15rem;
    font-size: 0.75rem;
    line-height: 1.35;
    color: #6b7280;
}

.matching-discover-toolbar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin: 0 0 0.35rem;
}

.matching-prefs-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #6b7280;
    cursor: pointer;
}

.matching-prefs-count {
    position: absolute;
    top: -0.2rem;
    right: -0.2rem;
    min-width: 1.05rem;
    height: 1.05rem;
    padding: 0 0.28rem;
    border-radius: 999px;
    background: #111827;
    color: #fff;
    font-size: 0.625rem;
    font-weight: 700;
    line-height: 1.05rem;
    text-align: center;
}

.matching-prefs-toggle:hover {
    background: #f3f4f6;
    color: #111827;
}

.matching-prefs-toggle.active {
    color: #111827;
    background: #e8eaed;
}

.matching-discover-preferences {
    flex: 1;
    min-height: 0;
    overflow: auto;
}

.matching-prefs-actions {
    display: flex;
    gap: 0.65rem;
}

.matching-prefs-actions .matching-btn,
.matching-prefs-actions .btn-primary {
    flex: 1;
}

.matching-panel { display: none; }
.matching-panel.active { display: block; }

#matching-content.matching-layout {
    overflow: visible;
}

#matching-content .matching-tabs {
    flex-shrink: 0;
}

#panel-discover.matching-panel.active {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

#panel-matches.matching-panel.active,
#panel-messages.matching-panel.active,
#panel-blocked.matching-panel.active {
    display: block;
}

#discover-deck {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

#discover-deck[hidden] {
    display: none !important;
}

#discover-content {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* Hide content column only if no panel is active */
.matching-content-col:not(:has(.matching-panel.active)) {
    display: none;
}

.matching-panel-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.matching-field {
    display: block;
    margin-bottom: 1rem;
}

.matching-toggle-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin: 0 0 1.25rem;
    padding: 0.9rem 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: #f9fafb;
    cursor: pointer;
}

.matching-toggle-copy {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.matching-toggle-title {
    font-weight: 600;
    color: #111827;
}

.matching-toggle-hint {
    font-size: 0.875rem;
    line-height: 1.4;
    color: #6b7280;
}

.matching-toggle-input {
    width: 1.15rem;
    height: 1.15rem;
    margin-top: 0.15rem;
    flex-shrink: 0;
    accent-color: #2563eb;
}

.matching-field > span {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.35rem;
    color: #1a1a1a;
}

.matching-field > .matching-field-hint {
    display: block;
    margin: 0.35rem 0 0;
    font-size: 0.75rem;
    font-weight: 400;
    line-height: 1.4;
    color: #6b7280;
}

.matching-nickname-status-ok {
    color: #047857 !important;
}

.matching-nickname-status-error {
    color: #b91c1c !important;
}

.matching-nickname-status-pending {
    color: #6b7280 !important;
}

.matching-privacy-hint {
    margin: 0 0 0.75rem !important;
    padding: 0.65rem 0.75rem;
    border-radius: 6px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    color: #475569 !important;
}

.matching-optional-badge {
    display: inline-block;
    margin-left: 0.35rem;
    padding: 0.1rem 0.4rem;
    border-radius: 999px;
    background: #f1f5f9;
    color: #64748b;
    font-size: 0.7rem;
    font-weight: 600;
    vertical-align: middle;
}

.matching-location-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.75rem;
}

.matching-location-grid.has-suburb {
    grid-template-columns: 1fr 1fr;
}

.matching-location-grid .matching-field-suburb {
    grid-column: 1 / -1;
}

.matching-suggest-wrap {
    position: relative;
}

.matching-suggest-list {
    position: absolute;
    z-index: 30;
    left: 0;
    right: 0;
    top: calc(100% + 2px);
    margin: 0;
    padding: 0.25rem 0;
    list-style: none;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
    max-height: 220px;
    overflow-y: auto;
}

.matching-suggest-item {
    display: block;
    width: 100%;
    text-align: left;
    border: 0;
    background: transparent;
    padding: 0.45rem 0.7rem;
    font: inherit;
    color: #1a1a1a;
    cursor: pointer;
}

.matching-suggest-item:hover {
    background: #f1f5f9;
}

.matching-field-nested {
    margin: 0;
}

.matching-field-nested > span {
    font-weight: 500;
    font-size: 0.8rem;
    color: #374151;
}

@media (max-width: 640px) {
    .matching-location-grid,
    .matching-location-grid.has-suburb {
        grid-template-columns: 1fr;
    }
}

.matching-field input,
.matching-field select,
.matching-field textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 0.55rem 0.65rem;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    font-size: 0.9rem;
    font-family: inherit;
    color: #1a1a1a;
    background: #fff;
    resize: vertical;
}

.matching-field input::placeholder,
.matching-field textarea::placeholder {
    color: #6b7280;
}

.matching-location-grid input::placeholder {
    color: #1a1a1a;
    opacity: 1;
}

.matching-field input:focus,
.matching-field select:focus,
.matching-field textarea:focus {
    outline: none;
    border-color: #1a1a1a;
    box-shadow: none;
}

.matching-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 0 0.85rem;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    background: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.matching-btn-pass { background: #dc2626; color: #fff; border-color: #dc2626; }
.matching-btn-like { background: #059669; color: #fff; border-color: #059669; }
.matching-btn-remove { align-self: end; }

.matching-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.75rem;
    align-items: end;
}

.matching-row-instrument {
    grid-template-columns: minmax(0, 1.4fr) minmax(7.5rem, 1fr) auto auto;
    grid-template-areas: "instrument level info delete";
}

.matching-row-instrument .matching-field-instrument {
    grid-area: instrument;
    overflow: visible;
}

.matching-row-instrument .matching-suggest-wrap {
    z-index: 31;
}

.matching-row-instrument .matching-icon-btn-delete {
    grid-area: delete;
    align-self: end;
}

.matching-row-instrument .matching-field-level {
    grid-area: level;
}

.matching-row-instrument .matching-level-info-btn {
    grid-area: info;
    align-self: end;
}

.matching-row-video {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
}

.matching-row-video .matching-field {
    margin-bottom: 0.75rem;
}

.matching-row-video .matching-btn-remove {
    align-self: flex-end;
    margin-top: 0.25rem;
}

.video-preview {
    width: 100%;
    margin-bottom: 0.75rem;
    border-radius: 8px;
    overflow: hidden;
    background: #111827;
}

.video-preview-facade {
    position: relative;
    isolation: isolate;
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    padding: 0;
    border: 0;
    cursor: pointer;
    background: #111827;
    color: inherit;
}

.video-preview-iframe,
.video-preview-video {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    border: 0;
    background: #000;
    object-fit: contain;
}

.video-preview-direct-poster {
    display: block;
    width: 100%;
    height: 100%;
    background: linear-gradient(160deg, #1f2937 0%, #111827 55%, #0b1220 100%);
}

.video-preview-direct-frame {
    position: absolute;
    inset: 0;
    z-index: 0;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.video-preview-direct-frame.is-ready {
    opacity: 1;
}

.video-preview-link {
    display: block;
    padding: 0.85rem 1rem;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    color: #111827;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
}

.video-preview-link:hover {
    background: #e5e7eb;
    color: #111827;
}

.video-preview-thumb {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-preview-play {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    background: rgba(17, 24, 39, 0.35);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
}

.video-preview-play-row {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
}

.video-preview-play-counter {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}

.video-preview-counter-badge {
    position: absolute;
    top: 0.55rem;
    right: 0.55rem;
    z-index: 2;
    padding: 0.2rem 0.45rem;
    border-radius: 6px;
    background: rgba(17, 24, 39, 0.55);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    pointer-events: none;
}

.video-preview-play-icon {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    color: #111827;
    font-size: 1.1rem;
    line-height: 1;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.video-preview-facade:hover .video-preview-play {
    background: rgba(17, 24, 39, 0.48);
}

.matching-repeatable { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 0.75rem; }
.matching-repeatable-item { padding: 0.75rem; border: 1px solid #e5e7eb; border-radius: 4px; background: #fafafa; overflow: visible; }

.matching-check-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.5rem;
}

#pref-instrument-search {
    margin-bottom: 0.5rem;
}

.matching-check-item[hidden] {
    display: none;
}

.matching-check-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    background: #fafafa;
    font-size: 0.85rem;
    white-space: nowrap;
    min-width: 0;
}

.matching-message { font-size: 0.85rem; color: #6b7280; margin: 0.5rem 0; }
.matching-message-success { color: #047857; }
.matching-message-error { color: #b91c1c; }

.matching-swipe-card .matching-message {
    margin: 0;
    font-size: 0.75rem;
    text-align: center;
    max-height: 2.4em;
    overflow: hidden;
}

.matching-empty {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    text-align: center;
    color: #6b7280;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    font-size: 0.875rem;
}

.matching-swipe-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    padding: 10px 12px;
    flex: 0 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow: hidden;
    box-sizing: border-box;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

/* Video area sizes to content (16:9), not leftover viewport height */
.matching-card-video-wrap {
    margin: 0;
    flex: 0 0 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
}

.matching-card-footer {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
}

.matching-video-grid {
    flex: 0 0 auto;
    display: grid;
    gap: 6px;
    width: 100%;
}

.matching-video-grid-1 {
    display: block;
}

/* Single video: full width, natural 16:9 */
.matching-video-grid-1 .matching-video-grid-item {
    aspect-ratio: 16 / 9;
    width: 100%;
    height: auto;
}

.matching-video-grid-1 .video-preview-facade,
.matching-video-grid-1 .video-preview-iframe,
.matching-video-grid-1 .video-preview-video,
.matching-video-grid-1 .video-preview-thumb,
.matching-video-grid-1 .video-preview-direct-frame {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.matching-video-grid-multi {
    grid-template-columns: 1fr 1fr;
}

.matching-video-grid-3 {
    grid-template-columns: 1fr 1fr;
}

.matching-video-grid-3 .matching-video-grid-item:first-child {
    grid-column: 1 / -1;
}

.matching-video-grid-item {
    min-height: 0;
    aspect-ratio: 16 / 9;
    width: 100%;
}

.matching-video-grid .video-preview-facade,
.matching-video-grid .video-preview-iframe,
.matching-video-grid .video-preview-video,
.matching-video-grid .video-preview-direct-frame {
    flex: 1;
    min-height: 0;
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
}

.matching-video-grid .video-preview-play-icon {
    width: 40px;
    height: 40px;
    font-size: 0.95rem;
}

.matching-video-open-btn {
    width: 100%;
    height: 100%;
    border: 0;
    cursor: pointer;
}

body.video-embed-modal-open {
    overflow: hidden;
}

.video-embed-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.video-embed-modal[hidden] {
    display: none !important;
}

.video-embed-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(17, 24, 39, 0.82);
}

.video-embed-modal-dialog {
    position: relative;
    z-index: 1;
    width: min(920px, 100%);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.video-embed-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    color: #fff;
}

.video-embed-modal-title {
    font-size: 0.95rem;
    font-weight: 600;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.video-embed-modal-close {
    border: 0;
    background: transparent;
    color: #fff;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.2rem 0.4rem;
}

.video-embed-modal-player {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: 10px;
    overflow: hidden;
}

.video-embed-modal-player .video-preview-iframe,
.video-embed-modal-player .video-preview-video,
.video-embed-modal-player .video-preview-facade {
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
}

.video-embed-modal-player .video-preview-link {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.matching-card-video {
    width: 100%;
    margin: 0;
    border-radius: 8px;
    overflow: hidden;
    background: #111827;
}

.matching-card-video.video-preview {
    position: relative;
    margin-bottom: 0;
    flex: 0 0 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    height: auto;
}

.matching-swipe-card .video-preview-facade,
.matching-swipe-card .video-preview-iframe,
.matching-swipe-card .video-preview-video,
.matching-swipe-card .video-preview-direct-frame {
    flex: 0 0 auto;
    min-height: 0;
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
}

.matching-card-video-empty {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    aspect-ratio: 16 / 9;
    width: 100%;
    color: #9ca3af;
    font-size: 0.9rem;
    background: #f3f4f6;
    border: 1px dashed #e5e7eb;
}

.matching-video-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 0.5rem;
    flex-shrink: 0;
}

.matching-video-nav-btn {
    width: 36px;
    height: 36px;
    border: 1px solid #e5e7eb;
    border-radius: 999px;
    background: #fff;
    color: #111827;
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
}

.matching-video-nav-btn:hover:not(:disabled) {
    background: #f9fafb;
}

.matching-video-nav-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.matching-video-dots {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    flex: 1;
}

.matching-video-dot {
    width: 8px;
    height: 8px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: #d1d5db;
    cursor: pointer;
}

.matching-video-dot.active {
    background: #111827;
    width: 18px;
}

.matching-video-caption {
    margin-top: 0.35rem;
    font-size: 0.8rem;
    color: #6b7280;
    text-align: center;
    flex-shrink: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.matching-card-header {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 0;
    flex-shrink: 0;
    text-align: left;
}

.matching-card-avatar-btn {
    display: block;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    flex-shrink: 0;
    border-radius: 50%;
    overflow: hidden;
    line-height: 0;
}

.matching-card-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    display: block;
}

.matching-card-avatar-empty {
    background: linear-gradient(135deg, #e5e7eb, #f3f4f6);
}

.matching-card-identity {
    min-width: 0;
    max-width: min(220px, calc(100% - 64px));
    text-align: left;
}

.matching-card-identity h3 {
    margin: 0;
    font-size: 1rem; /* 16sp */
    font-weight: 600;
    line-height: 1.25;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.matching-card-name-row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    min-width: 0;
    margin-bottom: 0.1rem;
}

.matching-about-btn {
    flex: 0 0 auto;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    color: #64748b;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.2;
    letter-spacing: 0.01em;
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
    white-space: nowrap;
}

.matching-about-btn:hover,
.matching-about-btn:focus-visible {
    color: #2563eb;
    outline: none;
}

.matching-about-modal {
    position: fixed;
    inset: 0;
    z-index: 2100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.matching-about-modal[hidden] {
    display: none;
}

.matching-about-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(17, 24, 39, 0.55);
}

.matching-about-modal-dialog {
    position: relative;
    z-index: 1;
    width: min(100%, 420px);
    max-height: min(80vh, 520px);
    overflow: auto;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.matching-about-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem 1rem 0.5rem;
}

.matching-about-modal-header h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
}

.matching-about-modal-close {
    border: 0;
    background: none;
    font-size: 1.5rem;
    line-height: 1;
    color: #6b7280;
    cursor: pointer;
}

.matching-about-modal-body {
    padding: 0.5rem 1rem 1.25rem;
    font-size: 0.95rem;
    line-height: 1.55;
    color: #111827;
    white-space: pre-wrap;
    word-break: break-word;
}

.matching-about-modal-body.is-empty {
    color: #6b7280;
    font-style: italic;
}

body.matching-about-modal-open {
    overflow: hidden;
}

.matching-card-media {
    width: 100%;
    max-width: 220px;
    max-height: 220px;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 4px;
    margin: 0 auto 1rem;
    display: block;
    background: #f3f4f6;
}

.matching-meta {
    color: #6b7280;
    font-size: 0.8rem;
    margin-bottom: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left;
}

.matching-image-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.matching-image-modal[hidden] {
    display: none !important;
}

.matching-image-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(17, 24, 39, 0.9);
}

.matching-image-modal-dialog {
    position: relative;
    z-index: 1;
    width: min(480px, 100%);
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.matching-image-modal-close {
    align-self: flex-end;
    border: 0;
    background: transparent;
    color: #fff;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.2rem 0.4rem;
}

.matching-image-modal-stage {
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: 8px;
    background: #000;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.matching-image-modal-photo {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    transform-origin: center center;
    will-change: transform;
    pointer-events: none;
}

.matching-image-modal-hint {
    margin: 0;
    text-align: center;
    color: rgba(255, 255, 255, 0.65);
    font-size: 0.8rem;
}

body.matching-image-modal-open {
    overflow: hidden;
}

.matching-tag-list {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    gap: 6px;
    margin: 0;
    flex-shrink: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.matching-tag-list::-webkit-scrollbar {
    display: none;
}

.matching-tag {
    font-size: 0.6875rem; /* 11sp */
    padding: 4px 10px;
    background: #eff6ff;
    color: #1d4ed8;
    border-radius: 4px;
    white-space: nowrap;
    flex-shrink: 0;
}

.matching-video-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.matching-swipe-actions {
    display: flex;
    gap: 12px;
    justify-content: stretch;
    flex-shrink: 0;
    width: 100%;
}

.matching-swipe-actions .matching-btn {
    flex: 1;
    max-width: none;
    min-height: 44px;
    height: 44px;
    padding: 0 12px;
}

.matching-block-row {
    text-align: center;
    margin: 0;
    flex-shrink: 0;
}

.matching-block-row .matching-btn {
    border: 0;
    background: transparent;
    color: #6b7280;
    font-size: 0.8125rem;
    font-weight: 500;
    min-height: 32px;
    height: 32px;
    padding: 0 12px;
}

.matching-block-row .matching-btn:hover {
    background: #f3f4f6;
    color: #4b5563;
}

.matching-list { display: flex; flex-direction: column; gap: 0.75rem; }

.matching-list-card {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    padding: 0.85rem;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    background: #fff;
}

.matching-list-card-media .matching-video-grid,
.matching-list-card-media .matching-card-video {
    min-height: 140px;
}

.matching-list-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.matching-list-card-header {
    justify-content: flex-start;
}

.matching-list-card-identity {
    max-width: none;
    flex: 1;
    min-width: 0;
}

.matching-list-card-identity h4 {
    margin: 0 0 0.15rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.matching-list-about {
    margin: 0;
    font-size: 0.85rem;
    line-height: 1.45;
    color: #374151;
    white-space: pre-wrap;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.matching-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    background: #fff;
}

.matching-list-item-main {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
    flex: 1;
}

.matching-list-item-text {
    min-width: 0;
}

.matching-list-avatar-btn {
    flex-shrink: 0;
}

.matching-list-item h4,
.matching-list-card h4 {
    font-size: 0.95rem;
    margin: 0 0 0.25rem;
}

.matching-list-item p { margin: 0; font-size: 0.85rem; color: #6b7280; }

.matching-list-actions {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.matching-list-card .matching-list-actions {
    margin-top: 0.15rem;
}

@media (max-width: 640px) {
    .matching-row:not(.matching-row-instrument) {
        grid-template-columns: 1fr;
    }
    .matching-list-item {
        flex-direction: column;
    }
}

/* Profile — layout parity with AndroidBasic ProfileScreen */
.match-profile-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin: 0 0 1rem;
}

.match-profile-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #1a1a1a;
}

.matching-toggle-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    cursor: pointer;
    flex-shrink: 0;
}

.matching-toggle-inline-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: #6b7280;
    white-space: nowrap;
}

.matching-toggle-inline .matching-toggle-input {
    margin-top: 0;
}

.match-profile-image-status {
    margin-bottom: 1rem;
}

.match-profile-image-hint {
    margin: 0;
    font-size: 0.75rem;
    line-height: 1.4;
    color: #6b7280;
}

.profile-save-btn {
    width: 100%;
    min-height: 48px;
}

.profile-crop-modal {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(17, 24, 39, 0.65);
}

.profile-crop-modal[hidden] {
    display: none !important;
}

.profile-crop-dialog {
    width: 100%;
    max-width: 360px;
    padding: 1.25rem;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
}

.profile-crop-title {
    margin: 0 0 0.35rem;
    font-size: 1rem;
    font-weight: 600;
}

.profile-crop-hint {
    margin: 0 0 1rem;
    font-size: 0.85rem;
    color: #6b7280;
}

.profile-crop-stage {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}

.profile-crop-viewport {
    position: relative;
    width: 300px;
    height: 300px;
    max-width: 100%;
    border-radius: 4px;
    overflow: hidden;
    touch-action: none;
    cursor: grab;
    user-select: none;
}

.profile-crop-viewport.dragging {
    cursor: grabbing;
}

.profile-crop-viewport.resizing {
    cursor: nwse-resize;
}

.profile-crop-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.profile-crop-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.profile-crop-frame {
    position: absolute;
    inset: 0;
    border: 2px solid rgba(255, 255, 255, 0.95);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15) inset;
}

.profile-crop-handle {
    pointer-events: auto;
    position: absolute;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    background: transparent;
    touch-action: none;
}

.profile-crop-handle::before,
.profile-crop-handle::after {
    content: '';
    position: absolute;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.profile-crop-handle[data-handle='nw'] {
    top: 0;
    left: 0;
    cursor: nwse-resize;
}

.profile-crop-handle[data-handle='nw']::before {
    top: 6px;
    left: 6px;
    width: 18px;
    height: 3px;
}

.profile-crop-handle[data-handle='nw']::after {
    top: 6px;
    left: 6px;
    width: 3px;
    height: 18px;
}

.profile-crop-handle[data-handle='ne'] {
    top: 0;
    right: 0;
    cursor: nesw-resize;
}

.profile-crop-handle[data-handle='ne']::before {
    top: 6px;
    right: 6px;
    width: 18px;
    height: 3px;
}

.profile-crop-handle[data-handle='ne']::after {
    top: 6px;
    right: 6px;
    width: 3px;
    height: 18px;
}

.profile-crop-handle[data-handle='sw'] {
    bottom: 0;
    left: 0;
    cursor: nesw-resize;
}

.profile-crop-handle[data-handle='sw']::before {
    bottom: 6px;
    left: 6px;
    width: 18px;
    height: 3px;
}

.profile-crop-handle[data-handle='sw']::after {
    bottom: 6px;
    left: 6px;
    width: 3px;
    height: 18px;
}

.profile-crop-handle[data-handle='se'] {
    bottom: 0;
    right: 0;
    cursor: nwse-resize;
}

.profile-crop-handle[data-handle='se']::before {
    bottom: 6px;
    right: 6px;
    width: 18px;
    height: 3px;
}

.profile-crop-handle[data-handle='se']::after {
    bottom: 6px;
    right: 6px;
    width: 3px;
    height: 18px;
}

.profile-crop-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* Profile — page shell; stack uses Tuner .web-page two-panel grid when wide */
.profile-page {
    padding: 20px;
    max-width: 1280px;
    width: 100%;
    box-sizing: border-box;
}

.profile-layout.web-page {
    width: 100%;
    max-width: none;
}

/* Until Match Profile loads, left panel uses full width */
.profile-layout.web-page:has(#match-profile-section[hidden]) {
    grid-template-columns: 1fr;
    max-width: 560px;
}

.profile-panel-left,
.profile-panel-right {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-height: 0;
    height: auto;
}

.profile-panel-right {
    background: #f9fafb;
}

.profile-panel-right .matching-form {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-height: 0;
}

.profile-hero {
    background: #f0f4f8;
    border-radius: 16px;
    padding: 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.profile-hero-photo-wrap {
    position: relative;
    width: min(72%, 280px);
    margin: 0 auto;
}

.profile-hero-photo-box {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 4px;
    border: 2px solid #e5e7eb;
    background: #e5e7eb;
    overflow: hidden;
    position: relative;
    cursor: pointer;
}

.profile-hero-photo {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-hero-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    height: 100%;
    color: #9ca3af;
}

.profile-hero-initials {
    font-size: 2.25rem;
    font-weight: 600;
    color: #6b7280;
    line-height: 1;
}

.profile-hero-placeholder-label {
    font-size: 0.8125rem;
}

.profile-hero-uploading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.35);
}

.profile-hero-spinner {
    width: 32px;
    height: 32px;
    border-width: 2px;
    border-color: rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
}

.profile-hero-edit-btn {
    position: absolute;
    right: -6px;
    bottom: -6px;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 999px;
    background: #fff;
    color: #1a1a1a;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.18);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2;
}

.profile-hero-edit-btn:hover {
    background: #f9fafb;
}

.profile-hero-edit-btn i {
    font-size: 0.95rem;
}

.profile-hero-name {
    margin: 16px 0 0;
    font-size: 1.375rem;
    font-weight: 600;
    color: #1a1a1a;
    line-height: 1.25;
}

.profile-hero-email {
    margin: 4px 0 0;
    font-size: 0.9375rem;
    color: #6b7280;
}

.profile-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.profile-section-title {
    margin: 0 0 4px;
    font-size: 1rem;
    font-weight: 600;
    color: #1a1a1a;
}

.profile-info-card {
    background: #fafafa;
    border-radius: 16px;
    padding: 8px 20px 12px;
}

.profile-info-item {
    padding: 12px 0;
    border-top: 1px solid #e5e7eb;
}

.profile-info-item-first {
    border-top: 0;
}

.profile-info-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: #6b7280;
    margin-bottom: 4px;
}

.profile-info-value {
    display: block;
    font-size: 1rem;
    color: #1a1a1a;
    word-break: break-word;
}

.profile-info-input {
    display: block;
    width: 100%;
    box-sizing: border-box;
    margin: 0;
    padding: 0.55rem 0.7rem;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: #fff;
    color: #1a1a1a;
    font-size: 1rem;
    line-height: 1.3;
}

.profile-info-input:focus {
    outline: none;
    border-color: #111;
}

.profile-info-hint {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.75rem;
    color: #6b7280;
    line-height: 1.35;
}

.profile-account-form {
    display: flex;
    flex-direction: column;
}

.profile-account-message {
    margin: 0.35rem 0 0;
    font-size: 0.85rem;
    line-height: 1.4;
}

.profile-account-message.is-error {
    color: #b91c1c;
}

.profile-account-message.is-success {
    color: #047857;
}

.profile-account-save-btn {
    margin-top: 0.85rem;
    width: 100%;
    min-height: 44px;
}

.profile-action-btn {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 18px;
    border: 0;
    border-radius: 14px;
    background: #fafafa;
    text-align: left;
    cursor: pointer;
    color: #1a1a1a;
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
}

.profile-action-btn:hover {
    background: #f3f4f6;
    color: inherit;
}

.profile-action-btn:visited {
    color: inherit;
}

.profile-action-danger,
.profile-action-danger:hover,
.profile-action-danger:visited {
    color: #dc2626;
}

.profile-action-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #f3f4f6;
    flex-shrink: 0;
    font-size: 1.1rem;
}

.profile-action-danger .profile-action-icon {
    color: #dc2626;
}

.profile-action-label {
    flex: 1;
    min-width: 0;
}

.profile-action-chevron {
    color: #9ca3af;
    flex-shrink: 0;
}
