/* Shared mobile/app visual system. Loaded after the legacy inline rules. */

/* Modal headers and close controls share one reliable alignment contract. */
.modal-content {
    box-sizing: border-box;
}

/* Blocking, honest feedback while a GIF or video is being rendered. */
.animation-export-progress {
    position: fixed;
    inset: 0;
    z-index: 16000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.animation-export-progress-card {
    width: min(360px, calc(100vw - 40px));
    padding: 24px;
    border: 1px solid rgba(88, 204, 2, 0.26);
    border-radius: 22px;
    background: var(--surface, #fff);
    color: var(--text, #263238);
    box-shadow: 0 20px 55px rgba(15, 23, 42, 0.24);
    text-align: center;
}

.animation-export-progress-icon {
    margin-bottom: 8px;
    font-size: 30px;
    line-height: 1;
}

.animation-export-progress-card h2 {
    margin: 0;
    font-size: 20px;
    line-height: 1.2;
}

.animation-export-progress-card p {
    min-height: 20px;
    margin: 7px 0 16px;
    color: var(--text-light, #667085);
    font-size: 14px;
}

.animation-export-progress-track {
    width: 100%;
    height: 12px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.22);
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.12);
}

.animation-export-progress-bar {
    width: 0%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #58cc02 0%, #20bce3 100%);
    box-shadow: 0 0 14px rgba(88, 204, 2, 0.4);
    transition: width 0.18s ease-out;
}

.animation-export-progress-percent {
    display: block;
    margin-top: 9px;
    color: var(--text, #263238);
    font-size: 13px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

body.dark-mode .animation-export-progress-card {
    border-color: rgba(88, 204, 2, 0.35);
    background: #1c1f24;
    color: #f8fafc;
}

body.dark-mode .animation-export-progress-card p,
body.dark-mode .animation-export-progress-percent {
    color: #d7dce4;
}

.modal-header {
    position: relative !important;
    display: flex;
    align-items: center !important;
    justify-content: flex-start !important;
    min-height: 72px;
    padding: 18px 68px 18px 24px !important;
    margin: 0 !important;
    border-bottom: 1px solid var(--community-border, #e5e7eb);
    flex-shrink: 0;
}

.modal-header h2 {
    width: 100%;
    margin: 0 !important;
    padding: 0 !important;
    font-size: clamp(20px, 4vw, 28px);
    line-height: 1.2;
}

.modal-header .close-modal,
.modal-content > .close-modal,
.modal-header .close-btn {
    position: absolute !important;
    top: 14px !important;
    right: 16px !important;
    float: none !important;
    width: 44px;
    height: 44px;
    margin: 0 !important;
    padding: 0 !important;
    border: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #667085;
    background: transparent;
    font-size: 32px !important;
    line-height: 1;
    cursor: pointer;
    z-index: 20;
}

.modal-header .close-modal:hover,
.modal-content > .close-modal:hover,
.modal-header .close-btn:hover {
    color: #111827;
    background: rgba(102, 112, 133, 0.12);
}

#communityGalleryModal .modal-content,
#createPostModal .modal-content,
#userProfileModal .modal-content,
#profileSettingsModal .modal-content,
#shareToCommunityModal .modal-content,
#termsModal .modal-content,
#myDesignsModal .modal-content {
    padding: 0 !important;
    overflow: hidden;
}

/* My Designs follows the same inset, rounded modal language as the rest of
   the app. The list scrolls independently and the retention status is a
   deliberate footer rather than loose text at the bottom of the viewport. */
#myDesignsModal {
    align-items: center;
    justify-content: center;
    padding: 18px !important;
    overflow: hidden !important;
}

#myDesignsModal .modal-content {
    display: flex !important;
    width: min(100%, 900px) !important;
    height: auto !important;
    max-height: calc(100dvh - 36px) !important;
    margin: auto !important;
    flex-direction: column;
    border: 1px solid var(--community-border, #e5e7eb);
    border-radius: 24px !important;
    background: #ffffff !important;
    color: #1f2937;
}

#myDesignsModal .my-designs-header {
    position: relative;
    top: auto;
    flex: 0 0 auto;
    padding: 20px 24px 16px;
    border-bottom: 1px solid #e7e9ed;
    background: #ffffff !important;
}

#myDesignsModal h2 {
    color: #111827 !important;
    font-size: clamp(26px, 5vw, 32px);
}

html body #myDesignsModal button.my-designs-close-btn {
    width: 44px !important;
    height: 44px !important;
    min-height: 44px !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 1px solid #dfe3e8 !important;
    background: #f3f4f6 !important;
    color: #4b5563 !important;
}

#myDesignsModal .designs-grid {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 16px 18px 6px !important;
}

#myDesignsModal .design-card {
    border: 1px solid #e6e8ec;
    background: #f7f8fa;
}

#myDesignsModal .design-card:hover {
    background: #f0f2f5;
}

#myDesignsModal .design-card h4 {
    color: #1f2937;
}

#myDesignsModal .design-card p {
    color: #667085;
}

#myDesignsModal .my-designs-summary {
    flex: 0 0 auto;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 0;
    padding: 14px 18px calc(14px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid #e7e9ed;
    background: #f8fafc;
    color: #344054;
}

.my-designs-summary-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 3px;
    line-height: 1.35;
}

.my-designs-summary-copy strong {
    font-size: 14px;
}

.my-designs-summary-copy span {
    color: #667085;
    font-size: 12px;
}

html body #myDesignsModal button.my-designs-pass-btn {
    width: auto !important;
    min-width: 140px;
    min-height: 44px !important;
    margin: 0 !important;
    padding: 10px 18px !important;
    flex: 0 0 auto;
}

body.dark-mode #myDesignsModal .modal-content,
body.dark-mode #myDesignsModal .my-designs-header {
    border-color: #30343b;
    background: #0b0d10 !important;
}

body.dark-mode #myDesignsModal h2 {
    color: #ffffff !important;
}

html body.dark-mode #myDesignsModal button.my-designs-close-btn {
    border-color: #414751 !important;
    background: #24282f !important;
    color: #f4f4f5 !important;
}

body.dark-mode #myDesignsModal .design-card {
    border-color: #363b43;
    background: #24272c;
}

body.dark-mode #myDesignsModal .design-card:hover {
    background: #2d3138;
}

body.dark-mode #myDesignsModal .design-card h4 {
    color: #ffffff;
}

body.dark-mode #myDesignsModal .design-card p,
body.dark-mode .my-designs-summary-copy span {
    color: #a8b0bc;
}

body.dark-mode #myDesignsModal .my-designs-summary {
    border-color: #30343b;
    background: #171a1f;
    color: #f1f3f5;
}

/* Purchase sheet uses its content height, avoiding both the crowded top and
   the stretched empty area created by the legacy flex modal. */
#upgradeModal {
    align-items: center;
    justify-content: center;
    padding: 16px !important;
    overflow: hidden !important;
}

#upgradeModal .upgrade-modal-content {
    width: min(100%, 600px) !important;
    height: auto !important;
    min-height: 0 !important;
    max-width: 600px !important;
    max-height: calc(100dvh - 32px) !important;
    margin: auto !important;
    padding: 24px !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    border-radius: 24px !important;
}

.upgrade-modal-intro {
    padding: 2px 38px 0;
    text-align: center;
}

#upgradeModal .upgrade-modal-intro h2 {
    margin: 0;
    font-size: clamp(21px, 4.8vw, 27px);
    line-height: 1.25;
}

#upgradeModal .upgrade-modal-intro p {
    margin: 7px 0 0;
    color: #667085;
    font-size: 14px;
    line-height: 1.4;
}

#upgradeModal .upgrade-benefits {
    margin: 18px 0 16px !important;
    padding: 16px 18px !important;
    border: 1px solid #e7e9ed;
    border-radius: 15px !important;
    background: #f8f9fb !important;
}

#upgradeModal .upgrade-benefits h3 {
    margin: 0 0 9px !important;
    font-size: 15px !important;
}

#upgradeModal .upgrade-benefits ul {
    padding: 0;
    margin: 0;
    list-style: none;
}

#upgradeModal .upgrade-benefits li {
    padding: 3px 0 !important;
    font-size: 13px !important;
    line-height: 1.35;
}

#upgradeModal .upgrade-options {
    display: flex;
    margin: 0 0 16px !important;
    flex-direction: column;
    gap: 11px !important;
}

#upgradeModal .pass-option {
    padding: 13px 14px !important;
    border-radius: 13px;
}

html body #upgradeModal button#purchasePassBtn {
    min-height: 50px !important;
    margin: 0 !important;
    padding: 12px 16px !important;
}

html body #upgradeModal button#restorePurchasesBtn {
    min-height: 44px !important;
    margin: 8px 0 0 !important;
    padding: 8px 12px !important;
}

#upgradeModal .upgrade-secure-note {
    margin: 8px auto 0 !important;
    max-width: 450px;
    color: #8a919e;
    font-size: 12px;
    line-height: 1.4;
    text-align: center;
}

body.dark-mode #upgradeModal .upgrade-benefits {
    border-color: #363b43;
    background: #24282f !important;
}

body.dark-mode #upgradeModal .upgrade-modal-intro p,
body.dark-mode #upgradeModal .upgrade-secure-note {
    color: #a8b0bc;
}

/* Guides close action is a stable header control, not a generic full-size
   mobile button. */
.guides-modal-header {
    padding-right: 76px !important;
}

html body #guidesModal button.guides-modal-close {
    top: 14px !important;
    right: 16px !important;
    width: 42px !important;
    height: 42px !important;
    min-height: 42px !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 1px solid rgba(255, 255, 255, 0.28) !important;
    border-radius: 50% !important;
    line-height: 1 !important;
}

.guide-step-content {
    min-width: 0;
}

/* Community search and sort form one clean toolbar; the native select itself
   remains borderless so Dark Mode cannot draw a second box inside the capsule. */
.community-filters {
    grid-template-columns: minmax(0, 1fr) minmax(150px, 200px);
    gap: 10px;
    padding: 12px 20px;
}

.community-search-control,
.community-sort-control {
    border: 1px solid var(--community-border);
    border-radius: 14px;
    box-shadow: none;
}

.filter-select,
body.dark-mode select.filter-select,
.filter-select:focus,
body.dark-mode select.filter-select:focus {
    appearance: none;
    -webkit-appearance: none;
    border: 0 !important;
    outline: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
}

.empty-state,
.empty-state h3,
.empty-state p {
    width: 100%;
    text-align: center !important;
}

.empty-state p {
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.45;
}

/* Create Post is one continuous surface instead of a grey body nested in a
   differently colored modal frame. */
#createPostModal .modal-content,
#createPostModal .modal-header,
#createPostModal .modal-body {
    background: #ffffff;
}

#createPostModal .design-selection-grid {
    background: #f7f8fa;
    border: 1px solid #e6e8ec;
}

body.dark-mode #createPostModal,
body.dark-mode #createPostModal .modal-content,
body.dark-mode #createPostModal .modal-header,
body.dark-mode #createPostModal .modal-body {
    background: #0b0d10 !important;
}

body.dark-mode #createPostModal .design-selection-grid {
    background: transparent !important;
    border-color: #30343b;
}

body.dark-mode .modal-header .close-modal,
body.dark-mode .modal-content > .close-modal,
body.dark-mode .modal-header .close-btn {
    color: #f4f4f5 !important;
}

body.dark-mode .modal-header .close-modal:hover,
body.dark-mode .modal-content > .close-modal:hover,
body.dark-mode .modal-header .close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Notification cards align the state icon and complete text block on one
   vertical center line, while the timestamp stays at the upper right. */
.notification-item {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    align-items: center;
    column-gap: 12px;
    min-height: 104px;
    padding: 14px 16px !important;
}

.notification-item.unread::before {
    display: none;
}

.notification-avatar.notification-status-icon {
    position: static !important;
    grid-column: 1;
    grid-row: 1;
    align-self: center;
    justify-self: center;
    width: 40px;
    height: 40px;
    transform: none;
    font-size: 19px;
    line-height: 1;
    box-shadow: 0 3px 10px rgba(35, 45, 65, 0.14);
}

.notification-status-icon.is-unread {
    background: linear-gradient(135deg, #58cc02, #20b9cf);
    color: #ffffff;
}

.notification-status-icon.is-viewed {
    background: #e9edf2;
    color: #667085;
    box-shadow: none;
}

.notification-content {
    grid-column: 2;
    grid-row: 1;
    align-self: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    padding-left: 0 !important;
}

.notification-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.notification-heading-group {
    display: flex;
    min-width: 0;
    align-items: center;
    gap: 6px;
}

.notification-title {
    min-width: 0;
    line-height: 1.3;
}

.notification-time {
    align-self: center;
    margin: 0;
    white-space: nowrap;
    text-align: right;
}

.notification-message {
    margin: 4px 0 0;
    line-height: 1.35;
}

.notification-delete {
    top: auto;
    right: 6px;
    bottom: 4px;
}

body.dark-mode .notification-status-icon.is-viewed {
    background: #343a43 !important;
    color: #cbd2dc !important;
}

/* Achievement metadata can wrap as a unit on narrow cards. */
.pokedex-entry {
    min-width: 0;
    overflow: hidden;
}

.pokedex-entry-meta {
    min-width: 0;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 8px;
}

.pokedex-entry-category {
    min-width: 0;
    max-width: 100%;
    overflow-wrap: anywhere;
    text-align: center;
}

/* The two primary Canvas actions always share one clean, balanced row. */
.canvas-action-buttons {
    width: min(100%, 600px);
    margin-left: auto;
    margin-right: auto;
}

.animation-primary-actions {
    display: grid;
    grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
    gap: 12px;
}

html body .canvas-action-buttons .animation-primary-actions > button.btn.animation-action-btn,
html body .canvas-action-buttons .animation-secondary-actions > button.btn {
    width: 100% !important;
    min-width: 0;
    min-height: 52px !important;
    margin: 0 !important;
    padding: 11px 14px !important;
}

.animation-action-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border-radius: 15px !important;
    font-size: 14px !important;
    line-height: 1.15;
    white-space: nowrap;
}

#downloadAnimationBtn {
    padding-inline: 9px !important;
    letter-spacing: -0.01em;
}

#downloadAnimationBtn .action-label-full,
#downloadAnimationBtn .action-label-short {
    min-width: 0;
    white-space: nowrap;
}

.action-label-short {
    display: none;
}

.animation-secondary-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
}

.animation-secondary-actions .btn {
    flex: 1 1 180px;
    max-width: 280px;
}

/* Format is selected after Download is tapped, in a focused bottom sheet. */
#animationFormatModal {
    align-items: center;
    justify-content: center;
    padding: 18px;
}

#animationFormatModal .animation-format-modal-content {
    width: min(100%, 430px);
    max-height: none;
    margin: 0;
    padding: 0 !important;
    overflow: hidden;
    border-radius: 22px;
}

.animation-format-modal-body {
    padding: 20px;
}

.animation-format-modal-body > p {
    margin: 0 0 18px;
    color: var(--text-light, #667085);
    font-size: 14px;
    line-height: 1.5;
}

.animation-format-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

html body #animationFormatModal button.animation-format-option {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
    min-height: 82px !important;
    padding: 14px !important;
    border: 1px solid var(--border, #dfe3e8) !important;
    border-radius: 16px !important;
    background: var(--surface, #ffffff) !important;
    color: var(--text, #1f2937) !important;
    text-align: left;
    box-shadow: 0 6px 18px rgba(30, 41, 59, 0.08) !important;
}

html body #animationFormatModal button.animation-format-option:hover,
html body #animationFormatModal button.animation-format-option:focus-visible {
    border-color: var(--green, #58cc02) !important;
    transform: translateY(-2px);
    outline: 3px solid rgba(88, 204, 2, 0.14);
}

.animation-format-icon {
    font-size: 28px;
    line-height: 1;
}

.animation-format-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 3px;
}

.animation-format-copy strong {
    font-size: 16px;
}

.animation-format-copy small {
    color: var(--text-light, #667085);
    font-size: 12px;
}

body.dark-mode #animationFormatModal .animation-format-modal-content,
body.dark-mode #animationFormatModal .modal-header,
body.dark-mode .animation-format-modal-body {
    background: var(--surface, #17191d) !important;
}

html body.dark-mode #animationFormatModal button.animation-format-option {
    border-color: #3b414a !important;
    background: #24282f !important;
    color: #ffffff !important;
}

body.dark-mode .animation-format-copy small,
body.dark-mode .animation-format-modal-body > p {
    color: #b8c0cc;
}

#sequencePdfSizeModal {
    align-items: center;
    justify-content: center;
    padding: 18px;
}

#sequencePdfSizeModal .sequence-pdf-size-content {
    width: min(100%, 460px);
    max-height: none;
    margin: 0;
    padding: 0 !important;
    overflow: hidden;
    border-radius: 22px;
}

.sequence-pdf-size-options {
    display: grid;
    gap: 10px;
}

html body #sequencePdfSizeModal button.sequence-pdf-size-option {
    position: relative;
    display: grid;
    gap: 4px;
    width: 100%;
    min-height: 68px !important;
    padding: 13px 15px !important;
    border: 1px solid var(--border, #dfe3e8) !important;
    border-radius: 15px !important;
    background: var(--surface, #ffffff) !important;
    color: var(--text, #1f2937) !important;
    text-align: left;
    box-shadow: none !important;
}

.sequence-pdf-size-option strong { font-size: 16px; }
.sequence-pdf-size-option span { color: var(--text-light, #667085); font-size: 13px; }
.sequence-pdf-size-option small {
    position: absolute;
    top: 12px;
    right: 13px;
    color: var(--green-dark, #3f9b00);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

html body #sequencePdfSizeModal button.sequence-pdf-size-option.is-recommended {
    border-color: var(--green, #58cc02) !important;
    background: color-mix(in srgb, var(--green, #58cc02) 6%, var(--surface, #ffffff)) !important;
}

body.dark-mode #sequencePdfSizeModal .sequence-pdf-size-content,
body.dark-mode #sequencePdfSizeModal .modal-header,
body.dark-mode #sequencePdfSizeModal .animation-format-modal-body {
    background: #17191d !important;
}

html body.dark-mode #sequencePdfSizeModal button.sequence-pdf-size-option {
    border-color: #3b414a !important;
    background: #24282f !important;
    color: #ffffff !important;
}

body.dark-mode .sequence-pdf-size-option span { color: #b8c0cc; }

@media (max-width: 768px) {
    #sequencePdfSizeModal {
        align-items: flex-end;
        padding: 14px;
        padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    }
}

/* Sequence navigation: fixed-width actions flank a flexible status card. */
.sequence-controls {
    grid-template-columns: minmax(96px, 1fr) minmax(128px, 1.25fr) minmax(96px, 1fr) !important;
    align-items: stretch !important;
    gap: 12px !important;
    width: min(100%, 620px) !important;
    margin: 18px auto !important;
}

html body #sequenceTab .sequence-controls > button.nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100% !important;
    min-width: 0 !important;
    min-height: 58px !important;
    margin: 0 !important;
    padding: 10px 12px !important;
    border-radius: 15px !important;
    line-height: 1.15;
    white-space: nowrap;
}

.sequence-controls .sequence-counter {
    display: flex;
    min-width: 0 !important;
    padding: 8px 6px !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(88, 204, 2, 0.3);
    border-radius: 15px;
    background: rgba(88, 204, 2, 0.07);
    line-height: 1.2 !important;
    white-space: normal !important;
}

.sequence-counter-progress,
.sequence-counter-pin {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap !important;
}

.sequence-counter-progress {
    font-size: 0.86em;
    color: var(--text-light, #667085);
}

.sequence-counter-pin {
    margin-top: 4px !important;
    font-size: 0.92em;
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 100%;
    overflow: visible;
    text-overflow: clip;
}

.sequence-counter-pin-label,
.sequence-counter-percentage {
    flex: 0 0 auto;
}

.sequence-complete-check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25em;
    height: 1.25em;
    border-radius: 50%;
    background: var(--green);
    color: #fff;
    font-family: system-ui, -apple-system, sans-serif;
    font-size: 0.9em;
    font-weight: 900;
    line-height: 1;
}

body.dark-mode .sequence-controls .sequence-counter {
    border-color: rgba(88, 204, 2, 0.38);
    background: rgba(88, 204, 2, 0.1);
}

/* A compact three-row pin viewport. Advancing beyond the final visible cell
   swaps in the next page, placing the new active step at the upper left. */
html body #sequenceDisplay.sequence-container {
    display: grid !important;
    grid-template-columns: repeat(var(--sequence-columns, 4), minmax(0, 1fr));
    grid-auto-rows: minmax(42px, auto);
    gap: 8px;
    min-height: 142px;
    max-height: none !important;
    padding: 12px !important;
    overflow: hidden !important;
    white-space: normal !important;
}

#sequenceDisplay .sequence-item {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    min-width: 0;
    min-height: 70px;
    align-items: center;
    justify-content: center;
    padding: 8px 6px;
    border: 1px solid rgba(148, 163, 184, 0.26);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.62);
    font-size: clamp(14px, 3.6vw, 17px);
    font-weight: 800;
    line-height: 1.12;
    text-align: center;
    overflow: hidden;
    overflow-wrap: normal;
    word-break: normal;
    box-shadow: inset 0 3px 0 var(--sequence-thread-color, #94a3b8);
}

#sequenceDisplay .sequence-pin-main,
#sequenceDisplay .sequence-pin-color,
#sequenceDisplay .sequence-pin-color-row {
    display: block;
    max-width: 100%;
    white-space: nowrap;
    word-break: keep-all;
    overflow-wrap: normal;
}

#sequenceDisplay .sequence-pin-main {
    display: inline-flex;
    width: auto;
    align-items: baseline;
    justify-content: center;
    gap: 3px;
    color: #1f2937 !important;
    font-size: clamp(15px, 3.8vw, 17px);
    font-weight: 800;
    letter-spacing: 0;
    line-height: 1.05;
    -webkit-text-stroke: 0 !important;
    text-shadow: none !important;
}

#sequenceDisplay .sequence-pin-color-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: 100%;
    margin-top: 7px;
}

#sequenceDisplay .sequence-color-dot {
    display: block;
    flex: 0 0 9px;
    width: 9px;
    height: 9px;
    border: 1px solid rgba(100, 116, 139, 0.7);
    border-radius: 50%;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35);
}

#sequenceDisplay .sequence-pin-color {
    overflow: visible;
    color: var(--text, #334155) !important;
    font-size: clamp(11.5px, 3vw, 13px);
    font-weight: 750;
    letter-spacing: -0.01em;
    line-height: 1;
    text-overflow: clip;
}

#sequenceDisplay .sequence-item--mono {
    min-height: 60px;
    padding: 8px;
    color: #1f2937 !important;
    font-size: clamp(18px, 4.8vw, 22px);
    font-weight: 800;
    line-height: 1;
    box-shadow: none;
    text-shadow: none !important;
    -webkit-text-stroke: 0 !important;
}

#sequenceDisplay .sequence-item.active {
    border-color: #ff4d67 !important;
    background: rgba(255, 77, 103, 0.09) !important;
    box-shadow: 0 0 0 2px rgba(255, 77, 103, 0.22) !important;
    transform: none !important;
}

body.dark-mode #sequenceDisplay {
    border-color: #3d434d;
    background: #17191d;
}

body.dark-mode #sequenceDisplay .sequence-item {
    border-color: #3e444e;
    background: #23262c;
}

body.dark-mode #sequenceDisplay .sequence-pin-main {
    color: #f8fafc !important;
}

body.dark-mode #sequenceDisplay .sequence-item--mono {
    color: #f8fafc !important;
}

body.dark-mode #sequenceDisplay .sequence-pin-color {
    color: #d7dce4 !important;
}

/* Keep the unread count vertically centered on the Notifications menu row.
   Static flex placement avoids the pulse animation displacing translateY(). */
#mobileNotificationsBtn {
    display: flex;
    align-items: center;
}

#mobileNotificationBadge {
    position: static !important;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    margin: 0 0 0 auto;
    padding: 0 6px;
    line-height: 18px;
    transform: none !important;
    animation: none !important;
}

/* Pattern Info: one concise row per spool and one selected unit at a time. */
#infoBox .thread-length-row {
    display: flex;
    align-items: baseline;
    gap: 5px;
    margin: 5px 0;
    min-width: 0;
    white-space: nowrap;
    font-size: clamp(13px, 3.4vw, 16px);
}

#infoBox .thread-length-row > span {
    min-width: 0;
}

#infoBox .thread-length-total {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border, #ddd);
    white-space: nowrap;
}

#infoBox .pattern-length-unit-toggle {
    display: flex;
    width: fit-content;
    margin: 12px auto 0;
    padding: 3px;
    border: 1px solid var(--border, #d8dde5);
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.12);
}

html body #infoBox .pattern-length-unit-toggle button {
    min-height: 0 !important;
    margin: 0 !important;
    padding: 5px 11px !important;
    border: 0 !important;
    border-radius: 999px !important;
    background: transparent !important;
    color: var(--text-light, #667085) !important;
    font-size: 11px !important;
    font-weight: 700;
    line-height: 1.1;
    box-shadow: none !important;
}

html body #infoBox .pattern-length-unit-toggle button.active {
    background: var(--green, #58cc02) !important;
    color: #ffffff !important;
}

body.dark-mode #infoBox .thread-length-total {
    border-color: #454b55;
}

body.dark-mode #infoBox .pattern-length-unit-toggle {
    border-color: #454b55;
    background: #22262c;
}

/* Custom palette modal */
#customPaletteModal .modal-content {
    width: min(92vw, 500px);
    max-height: min(88vh, 760px);
    padding: 24px !important;
    overflow-y: auto;
    border-radius: 22px !important;
}

.custom-palette-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.custom-palette-header h2,
.custom-palette-header p {
    margin: 0;
    text-align: left;
}

.custom-palette-header h2 { font-size: clamp(21px, 5vw, 28px); }
.custom-palette-header p { margin-top: 6px; color: #667085; }

#customPaletteModal .close-modal {
    display: inline-flex;
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    align-items: center;
    justify-content: center;
    margin: -5px -5px 0 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #f2f4f7;
    color: #344054;
    font-size: 28px;
    line-height: 1;
}

#customPaletteModal .custom-color-item {
    display: grid;
    grid-template-columns: 28px 58px minmax(0, 1fr);
    gap: 10px;
    padding: 11px;
}

#customPaletteModal .custom-color-item input[type="text"] {
    width: 100%;
    min-width: 0;
    color: #344054 !important;
    background: #fff;
}

body.dark-mode #customPaletteModal .modal-content {
    border: 1px solid #353a43;
    background: #111316 !important;
    color: #f8fafc;
}

body.dark-mode .custom-palette-header h2 { color: #f8fafc; }
body.dark-mode .custom-palette-header p { color: #aeb7c4; }
body.dark-mode #customPaletteModal .close-modal {
    background: #292d34 !important;
    color: #fff !important;
}

body.dark-mode #customPaletteModal .custom-color-item {
    border-color: #3b414b;
    background: #202329;
}

body.dark-mode #customPaletteModal .custom-color-item input[type="text"] {
    border-color: #484f5b;
    background: #14161a;
    color: #f8fafc !important;
}

body.dark-mode #customPaletteModal .btn-secondary:not(:disabled),
body.dark-mode #customPaletteModal .btn-primary:not(:disabled),
body.dark-mode .animation-format-option:not(:disabled),
body.dark-mode .btn-download:not(:disabled) {
    color: #fff !important;
}

body.dark-mode .btn-secondary:not(:disabled),
body.dark-mode .nav-btn:not(:disabled),
body.dark-mode .voice-btn:not(:disabled),
body.dark-mode .animation-action-btn:not(:disabled) {
    color: #fff !important;
}

body.dark-mode #customPaletteModal .btn-secondary:not(:disabled),
body.dark-mode .animation-format-option:not(:disabled),
body.dark-mode .btn-download:not(:disabled) {
    border-color: #4a515d !important;
    background: #272b32 !important;
}

@media (max-width: 480px) {
    html body #sequenceDisplay.sequence-container {
        grid-template-columns: repeat(var(--sequence-columns, 3), minmax(0, 1fr));
    }
    #customPaletteModal .modal-content { padding: 18px !important; }
    #customPaletteModal .custom-color-item {
        grid-template-columns: 22px 50px minmax(0, 1fr);
        gap: 7px;
        padding: 9px;
    }
}

/* Native app: the frame tool stays discoverable without presenting a dead
   visualizer. */
#native3DModelNotice {
    max-width: 440px;
    margin: 14px auto 0;
    padding: 20px;
    border: 1px solid #dbe7f2;
    border-radius: 18px;
    background: #f6faff;
    text-align: left;
}

#native3DModelNotice strong {
    display: block;
    margin-bottom: 9px;
    color: var(--text, #273142);
    font-size: 17px;
    line-height: 1.3;
}

#native3DModelNotice span {
    display: block;
    color: #607080;
    font-size: 14px;
    line-height: 1.55;
}

#native3DModelNotice .btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: min(100%, 330px) !important;
    min-height: 50px;
    margin: 16px auto 0 !important;
    padding: 11px 16px !important;
    border-radius: 14px !important;
    text-align: center;
    text-decoration: none;
    white-space: normal;
}

/* The compact profile badge strip has a clear section label. */
.compact-achievements-heading {
    margin: 0 0 4px;
    color: var(--community-text, #1f2937);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.02em;
}

/* Compact profile action that reads as part of the identity block. */
html body button.profile-settings-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: max-content !important;
    max-width: 100%;
    min-height: 32px !important;
    margin: 7px 0 0 !important;
    padding: 5px 10px !important;
    border: 1px solid var(--community-border) !important;
    border-radius: 999px !important;
    background: transparent !important;
    color: var(--community-text) !important;
    font-size: 11.5px !important;
    font-weight: 700;
    line-height: 1;
    box-shadow: none !important;
}

html body button.profile-settings-button:hover {
    border-color: var(--community-accent) !important;
    background: rgba(255, 107, 157, 0.08) !important;
}

/* Persistent menu trigger: clear, useful, and visually restrained. */
.app-menu-trigger {
    position: relative;
    display: inline-grid;
    place-items: center;
    min-width: 72px;
    height: 38px;
    padding: 0 14px !important;
    margin: 0 !important;
    border: 1px solid var(--border, #d9dee7) !important;
    border-radius: 999px !important;
    background: var(--surface, #ffffff) !important;
    color: var(--text, #263238) !important;
    font-size: 14px !important;
    font-weight: 750 !important;
    letter-spacing: 0.01em;
    line-height: 1;
    text-align: center !important;
    box-sizing: border-box;
    box-shadow: 0 2px 8px rgba(30, 41, 59, 0.08) !important;
    cursor: pointer;
    transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.app-menu-trigger:hover,
.app-menu-trigger:focus-visible {
    border-color: var(--green, #58cc02) !important;
    background: color-mix(in srgb, var(--green, #58cc02) 6%, var(--surface, #ffffff)) !important;
}

.menu-unread-dot {
    position: absolute;
    top: 2px;
    right: 5px;
    width: 8px;
    height: 8px;
    border: 2px solid var(--surface, #ffffff);
    border-radius: 50%;
    background: var(--green, #58cc02);
    box-sizing: content-box;
}

.menu-unread-dot[hidden] { display: none !important; }

/* The trigger still carries the old hamburger class for its mobile behavior.
   Neutralize those legacy bar styles on the actual word and notification dot. */
.hamburger-menu-btn.app-menu-trigger > .app-menu-label,
.desktop-menu-trigger.app-menu-trigger > .app-menu-label {
    display: inline !important;
    width: auto !important;
    height: auto !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    opacity: 1 !important;
    transform: none !important;
    justify-self: center !important;
    align-self: center !important;
    line-height: 1 !important;
    text-align: center !important;
}

.hamburger-menu-btn.app-menu-trigger > .menu-unread-dot,
.desktop-menu-trigger.app-menu-trigger > .menu-unread-dot {
    width: 8px !important;
    height: 8px !important;
    margin: 0 !important;
    border-radius: 50% !important;
    background: var(--green, #58cc02) !important;
    box-shadow: none !important;
    opacity: 1 !important;
    transform: none !important;
}

.hamburger-menu-btn.app-menu-trigger > .menu-unread-dot[hidden],
.desktop-menu-trigger.app-menu-trigger > .menu-unread-dot[hidden] {
    display: none !important;
}

.hamburger-menu-btn.app-menu-trigger {
    display: none;
    flex: 0 0 auto;
}

.app-menu-trigger:active,
.app-menu-trigger.active {
    transform: scale(0.94);
}

body.dark-mode .app-menu-trigger {
    border-color: #3b414a !important;
    background: #23272d !important;
    color: #f5f7fa !important;
}

/* A restrained label shadow keeps pale button text readable in both themes. */
button:not(.close-btn):not(.close-modal):not(.notification-bell-btn):not(.profile-menu-btn) {
    text-shadow: 0 1px 1px rgba(15, 23, 42, 0.2);
}

body.dark-mode button:not(.close-btn):not(.close-modal):not(.notification-bell-btn):not(.profile-menu-btn) {
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.68);
}

@media (max-width: 768px) {
    .header-content-wrapper {
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 12px !important;
        padding-inline: 14px !important;
        box-sizing: border-box;
    }

    .header-title {
        flex: 1;
        text-align: left !important;
    }

    .header-title h1 {
        text-align: left;
    }

    .hamburger-menu-btn.app-menu-trigger {
        display: grid !important;
        place-items: center !important;
        margin-left: auto;
    }

    /* Join the step navigator and current workspace into one intentional card. */
    .mobile-step-indicator {
        width: auto !important;
        margin: 12px 16px 0 !important;
        padding: 10px !important;
        border: 1px solid var(--border, #e5e7eb) !important;
        border-bottom: 0 !important;
        border-radius: 22px 22px 0 0 !important;
        box-shadow: 0 7px 22px rgba(30, 41, 59, 0.08);
    }

    .main-content {
        padding: 0 16px 16px !important;
        gap: 0 !important;
    }

    body.mobile-step-1 .controls,
    body.mobile-step-2 .canvas-container,
    body.mobile-step-3 .canvas-container {
        width: 100% !important;
        margin-top: 0 !important;
        border: 1px solid var(--border, #e5e7eb);
        border-top: 0;
        border-radius: 0 0 22px 22px !important;
        box-shadow: 0 12px 26px rgba(30, 41, 59, 0.1);
    }

    .modal-header {
        min-height: 66px;
        padding: 16px 64px 16px 20px !important;
    }

    .modal-header .close-modal,
    .modal-content > .close-modal,
    .modal-header .close-btn {
        top: 11px !important;
        right: 12px !important;
    }

    #communityGalleryModal .modal-content,
    #createPostModal .modal-content,
    #userProfileModal .modal-content,
    #profileSettingsModal .modal-content {
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        max-height: 100% !important;
        margin: 0 !important;
        border-radius: 20px !important;
    }

    #createPostModal .modal-header {
        position: relative !important;
        top: auto !important;
        padding: 16px 64px 16px 20px !important;
    }

    #createPostModal .modal-body {
        padding: 20px !important;
        padding-bottom: calc(32px + env(safe-area-inset-bottom, 0px)) !important;
    }

    .community-filters {
        grid-template-columns: minmax(0, 1fr) minmax(122px, 38%);
        padding: 10px 14px;
    }

    .community-gallery-container {
        padding: 14px;
    }

    .profile-header {
        align-items: flex-start;
    }

    .animation-primary-actions,
    .animation-secondary-actions {
        gap: 8px;
    }

    .animation-primary-actions {
        grid-template-columns: minmax(0, 0.86fr) minmax(0, 1.14fr);
    }

    html body .canvas-action-buttons .animation-primary-actions > button.btn.animation-action-btn {
        min-height: 48px !important;
        padding: 10px 8px !important;
        font-size: 13px !important;
    }

    html body .canvas-action-buttons .animation-primary-actions > #downloadAnimationBtn {
        gap: 5px;
        padding-inline: 7px !important;
        font-size: clamp(12px, 3.15vw, 13px) !important;
    }

    .action-label-full {
        display: none;
    }

    .action-label-short {
        display: inline;
    }

    .sequence-controls {
        grid-template-columns: minmax(78px, 0.82fr) minmax(116px, 1.36fr) minmax(78px, 0.82fr) !important;
        gap: 8px !important;
        margin: 14px auto !important;
    }

    html body #sequenceTab .sequence-controls > button.nav-btn {
        min-height: 54px !important;
        padding: 9px 6px !important;
        font-size: clamp(12px, 3.3vw, 14px) !important;
    }

    .sequence-controls .sequence-counter {
        min-width: 0 !important;
        padding: 7px 4px !important;
        font-size: clamp(12px, 3.4vw, 15px) !important;
    }

    .sequence-counter-pin {
        gap: 3px;
        font-size: 0.88em;
    }

    #native3DModelNotice {
        padding: 18px 16px;
    }

    #native3DModelNotice .btn {
        font-size: 13px !important;
    }

    #animationFormatModal {
        align-items: flex-end;
        padding: 14px;
        padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    }

    #animationFormatModal .animation-format-modal-content {
        width: 100% !important;
        height: auto !important;
        max-width: 430px !important;
        border-radius: 22px !important;
    }

    .animation-format-options {
        gap: 10px;
    }

    html body #animationFormatModal button.animation-format-option {
        min-height: 76px !important;
        padding: 12px !important;
    }

    .notification-item {
        grid-template-columns: 42px minmax(0, 1fr);
        min-height: 100px;
        column-gap: 10px;
        padding: 13px 14px !important;
    }

    #myDesignsModal {
        padding: 12px !important;
    }

    #myDesignsModal .modal-content {
        width: 100% !important;
        height: calc(100dvh - 24px) !important;
        max-width: 100% !important;
        max-height: calc(100dvh - 24px) !important;
        margin: 0 !important;
        border-radius: 22px !important;
    }

    #myDesignsModal .my-designs-header {
        padding: 16px 18px 14px;
    }

    #myDesignsModal .designs-grid {
        padding: 12px 12px 4px !important;
    }

    #myDesignsModal .my-designs-summary {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px));
    }

    html body #myDesignsModal button.my-designs-pass-btn {
        width: 100% !important;
    }

    #upgradeModal {
        padding: 14px !important;
    }

    #upgradeModal .upgrade-modal-content {
        width: 100% !important;
        max-height: calc(100dvh - 28px) !important;
        padding: 20px 18px !important;
        border-radius: 22px !important;
    }

    .upgrade-modal-intro {
        padding: 3px 34px 0;
    }

    #upgradeModal .upgrade-benefits {
        margin: 15px 0 14px !important;
        padding: 14px 15px !important;
    }

    #upgradeModal .upgrade-options {
        margin-bottom: 14px !important;
        gap: 10px !important;
    }

    #upgradeModal .pass-option {
        padding: 12px !important;
    }

    .guides-modal-header {
        padding: 14px 64px 10px 14px !important;
    }

    html body #guidesModal button.guides-modal-close {
        top: 12px !important;
        right: 12px !important;
        width: 40px !important;
        height: 40px !important;
        min-height: 40px !important;
    }
}
