/* ===== Launcher page ===== */

body {
    min-height: 100%;
    display: flex;
    flex-direction: column;
}

/* The badge opens the changelog only on the launcher. */
.version-badge {
    cursor: pointer;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

#refresh-btn {
    font-size: 16px;
    color: var(--text-secondary);
}

/* ---- Pull-to-refresh hint ---- */
.pull-hint {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-color);
    background: var(--accent-soft);
    overflow: hidden;
    z-index: 60;
    pointer-events: none;
}

/* ---- Header ---- */
.launcher-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 20px 14px;
    background: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
}

.launcher-header .logo {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    background: var(--accent-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    flex-shrink: 0;
}

.launcher-header .header-text {
    flex: 1;
    min-width: 0;
}

.launcher-header h1 {
    font-size: 20px;
    font-weight: 700;
}

.launcher-header p {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---- Main ---- */
.launcher-main {
    flex: 1;
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    padding: 16px;
}

.search-box {
    position: relative;
    margin-bottom: 14px;
}

.search-box .search-icon {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 15px;
    opacity: 0.7;
    pointer-events: none;
}

.search-box input {
    padding: 12px 42px 12px 14px;
    border-radius: 12px;
    background: var(--bg-secondary);
    border-color: transparent;
}

.search-box input:focus {
    background: var(--input-bg);
    border-color: var(--accent-color);
}

/* LTR overrides */
[dir="ltr"] .search-box .search-icon {
    right: auto;
    left: 14px;
}

[dir="ltr"] .search-box input {
    padding: 12px 14px 12px 42px;
}

.stats {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    padding: 0 4px;
}

/* ---- App grid ---- */
.app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 12px;
    padding-bottom: 30px;
}

.app-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    border-radius: 16px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    transition: transform 0.12s, border-color 0.12s;
    overflow: hidden;
}

.app-card.ready:hover {
    border-color: var(--accent-color);
    transform: translateY(-2px);
}

.app-card.ready {
    cursor: pointer;
}

.app-card .info-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    font-size: 13px;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, border-color 0.15s;
}

.app-card .info-btn:active {
    transform: scale(0.9);
}

.app-card .info-btn:hover {
    color: var(--accent-color);
    border-color: var(--accent-color);
}

[dir="rtl"] .app-card .info-btn {
    right: auto;
    left: 10px;
}

.app-card .app-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    flex-shrink: 0;
}

.app-card .app-info {
    flex: 1;
    min-width: 0;
}

.app-card .app-info h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 3px;
}

.app-card .app-info .name-en {
    font-size: 11px;
    color: var(--text-secondary);
    direction: ltr;
    text-align: right;
}

[dir="ltr"] .app-card .app-info .name-en {
    text-align: left;
}

.app-card .app-info p {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
    line-height: 1.5;
}

.app-card .app-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 8px;
}

.app-card .app-tags .chip {
    padding: 2px 8px;
    font-size: 10px;
}

/* ---- Coming soon cards ---- */
.app-card.soon {
    opacity: 0.62;
    cursor: default;
    filter: saturate(0.6);
}

.soon-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 2px 8px;
    border-radius: 999px;
}

[dir="ltr"] .soon-badge {
    left: auto;
    right: 10px;
}

.app-grid .empty-state {
    grid-column: 1 / -1;
}

/* ---- App info sheet ---- */
.sheet-box {
    max-width: 420px;
}

.sheet-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.sheet-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    flex-shrink: 0;
}

.sheet-title {
    min-width: 0;
}

.sheet-title h3 {
    font-size: 17px;
    margin-bottom: 2px;
}

.sheet-en {
    font-size: 12px;
    color: var(--text-secondary);
    direction: ltr;
    text-align: right;
}

[dir="ltr"] .sheet-en {
    text-align: left;
}

.sheet-desc {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 10px;
}

.sheet-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 14px;
}

.sheet-sec-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.sheet-notes {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 18px;
}

.sheet-notes li {
    font-size: 13px;
    line-height: 1.6;
    background: var(--bg-secondary);
    border-radius: 10px;
    padding: 9px 12px;
}

.sheet-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.soon-cta {
    text-align: center;
    font-size: 13px;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 12px;
}

/* ---- Changelog sheet ---- */
#changelog-box {
    max-height: 78vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.cl-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 16px;
}

.cl-entry {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 10px 14px;
}

.cl-entry:first-child {
    border: 1px solid var(--accent-color);
}

.cl-ver {
    font-size: 13px;
    font-weight: 700;
    color: var(--accent-color);
    direction: ltr;
    text-align: right;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
}

.cl-ver .cl-icon {
    font-size: 15px;
}

[dir="ltr"] .cl-ver {
    text-align: left;
}

.cl-lines {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 13px;
    line-height: 1.55;
}

.cl-lines li::before {
    content: '• ';
    color: var(--text-secondary);
}

.cl-actions {
    margin-top: 8px;
}

.cl-link {
    width: 100%;
    font-size: 12px;
    padding: 8px;
}
/* ===== Data & backups (header button, reminder bar, backup sheet) ===== */

#backup-btn {
    font-size: 15px;
}

.backup-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 2px 20px 10px;
    padding: 10px 12px;
    background: var(--accent-soft);
    border: 1px solid var(--border-color);
    border-radius: 14px;
}

.backup-bar .backup-bar-ico {
    font-size: 18px;
    flex-shrink: 0;
}

.backup-bar .backup-bar-txt {
    flex: 1;
    min-width: 0;
}

.backup-bar-title {
    font-weight: 600;
    font-size: 13px;
}

.backup-bar-sub {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.backup-bar .bk-small {
    flex-shrink: 0;
    padding: 6px 12px;
    font-size: 12px;
    margin: 0;
}

.backup-x {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    padding: 2px 6px;
    border-radius: 8px;
    flex-shrink: 0;
}

/* ---- Backup sheet ---- */
.bk-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 40vh;
    overflow-y: auto;
    margin: 12px 0;
    -webkit-overflow-scrolling: touch;
}

.bk-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: var(--bg-soft, transparent);
    border: 1px solid var(--border-color);
    border-radius: 12px;
}

.bk-ico {
    font-size: 22px;
    flex-shrink: 0;
}

.bk-meta {
    flex: 1;
    min-width: 0;
}

.bk-name {
    font-weight: 600;
    font-size: 14px;
}

.bk-date {
    font-size: 12px;
    color: var(--text-secondary);
}

.bk-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.bk-actions .btn {
    flex: 1 1 45%;
    margin: 0;
}

/* ---- Password area ---- */
.pw-area {
    border-top: 1px solid var(--border-color);
    padding-top: 12px;
}

.pw-title {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 8px;
}

.pw-input {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--card-bg, #fff);
    color: var(--text-color);
    font-size: 14px;
    margin-bottom: 8px;
}

.pw-err {
    color: #e0555a;
    font-size: 12px;
    min-height: 16px;
    margin-top: 2px;
}

.pw-btns {
    display: flex;
    gap: 8px;
    margin-top: 6px;
}

.pw-btns .btn {
    flex: 1;
    margin: 0;
}

/* ===== Theme picker ===== */

#theme-btn {
    font-size: 15px;
}

.th-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 12px 0;
}

.th-row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: transparent;
    text-align: start;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.th-row.active {
    border-color: var(--accent-color);
    background: var(--accent-soft);
}

.th-dot {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.th-dot-default {
    background: linear-gradient(135deg, #0088cc 0%, #50a9e8 55%, #34c7f5 100%);
}

.th-name {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
}

.th-check {
    color: var(--accent-color);
    font-weight: 700;
    font-size: 15px;
}

/* ===== Restore: drop hint + card backup chips ===== */

/* Generic visibility toggle (launcher pages only — apps have their own). */
.hidden {
    display: none !important;
}

.drop-hint {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--modal-bg);
    pointer-events: none;
}

.drop-hint::before {
    content: '';
    position: absolute;
    inset: 18px;
    border: 2px dashed var(--accent-color);
    border-radius: 18px;
}

.drop-hint span {
    position: relative;
    background: var(--card-bg);
    color: var(--accent-color);
    font-weight: 700;
    font-size: 15px;
    padding: 14px 22px;
    border-radius: 14px;
    box-shadow: var(--shadow);
}

.card-backup {
    margin-top: 8px;
    font-size: 11px;
    color: var(--text-secondary);
}

.card-backup span {
    font-weight: 600;
}

[dir="rtl"] .card-backup {
    text-align: right;
}
