:root {
    --bg-color: #050505;
    --surface-color: #121212;
    --input-bg: #1a1a1a;
    --border-color: #333;
    --text-primary: #e0e0e0;
    --text-secondary: #888;
    --accent-color: #fff;
    --btn-bg: #222;
    --active-nav: #fff;
    --paste-btn-color: #7aa2f7;
    --paste-btn-bg: rgba(122, 162, 247, 0.1);
    --radius: 18px;
    --toast-bg: #fff;
    --toast-text: #000;
    --app-max-width: 480px;
    --desktop-bg-color: #1E1E1E;
}

body.light-mode {
    --bg-color: #f2f2f7;
    --surface-color: #ffffff;
    --input-bg: #f5f5f5;
    --border-color: #d1d1d6;
    --text-primary: #1c1c1e;
    --text-secondary: #8e8e93;
    --accent-color: #007aff;
    --btn-bg: #ffffff;
    --active-nav: #222;
    --paste-btn-color: #007aff;
    --paste-btn-bg: rgba(0, 122, 255, 0.1);
    --toast-bg: #333;
    --toast-text: #fff;
    --desktop-bg-color: #1E1E1E;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    outline: none;
    font-family: 'Vazirmatn', sans-serif !important;
}

html,
body {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

*::-webkit-scrollbar {
    width: 0;
    height: 0;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-primary);
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: background-color 0.3s, color 0.3s;
}

input,
textarea {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

#output-send,
#output-receive {
    -webkit-user-select: none;
    user-select: none;
}

body,
main {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

body::-webkit-scrollbar,
main::-webkit-scrollbar {
    width: 0;
    height: 0;
}

header {
    padding: 15px;
    text-align: center;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
    background: rgba(5, 5, 5, 0.35);
    backdrop-filter: blur(18px) saturate(140%);
    -webkit-backdrop-filter: blur(18px) saturate(140%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    height: 55px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}

body.light-mode header {
    background: rgba(255, 255, 255, 0.7);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
}

header h1 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    opacity: 0.9;
}

.app-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.app-logo .logo {
    height: 22px;
    width: auto;
    display: block;
}

.app-logo .logo-light {
    display: none;
}

body.light-mode .app-logo .logo-dark {
    display: none;
}

body.light-mode .app-logo .logo-light {
    display: block;
}

main {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 15px;
    padding-top: calc(15px + 55px);
    padding-bottom: 90px;
}

.converter-box {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
    transition: background-color 0.3s;
}

.input-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px 0 15px;
}

.input-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.input-area,
.output-area {
    padding: 15px;
    position: relative;
}

.divider {
    height: 1px;
    background: var(--border-color);
    position: relative;
    margin: 0 15px;
}

.divider::after {
    content: "▼";
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background: var(--surface-color);
    padding: 0 10px;
    color: var(--text-secondary);
    font-size: 10px;
    transition: background-color 0.3s;
}

label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.paste-btn-mini {
    background: var(--paste-btn-bg);
    color: var(--paste-btn-color);
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    font-weight: 500;
}

.icon-btn-mini {
    padding: 6px;
    width: 30px;
    height: 30px;
    justify-content: center;
}

.icon-btn-mini svg {
    width: 16px;
    height: 16px;
}

.icon-btn-mini .icon-spinner {
    display: none;
}

.icon-btn-mini.is-loading .icon-location {
    display: none;
}

.icon-btn-mini.is-loading .icon-spinner {
    display: block;
    animation: spin 0.85s linear infinite;
}

.icon-btn-mini[disabled] {
    cursor: default;
    opacity: 0.6;
}

.paste-btn-mini:active {
    transform: scale(0.95);
    opacity: 0.8;
}

.paste-btn-mini svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}

textarea {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1rem;
    resize: none;
    height: 110px;
    line-height: 1.6;
    padding: 10px 0;
}

textarea::placeholder {
    color: var(--text-secondary);
    opacity: 0.5;
}

.output-area textarea {
    color: var(--text-primary);
    font-weight: 500;
}

.action-btn {
    background: var(--btn-bg);
    color: var(--text-primary);
    border: none;
    width: 100%;
    padding: 16px;
    font-size: 1rem;
    font-weight: 700;
    text-align: center;
    cursor: pointer;
    border-top: 1px solid var(--border-color);
    transition: background-color 0.3s;
}

.action-btn:active {
    opacity: 0.8;
    background: var(--input-bg);
}

.bottom-nav {
    position: fixed;
    bottom: 20px;
    left: 20px;
    right: 20px;
    height: 65px;
    background: rgba(18, 18, 18, 0.5);
    backdrop-filter: blur(18px) saturate(120%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 24px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 20;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    transition: background-color 0.3s, border-color 0.3s;
}

.nav-item {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 10px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.7rem;
    transition: all 0.2s;
    width: 60px;
}

.nav-item svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
    margin-bottom: 4px;
}

.flip-x {
    transform: scaleX(-1);
}

.nav-item.active {
    color: var(--active-nav);
    transform: translateY(-2px);
}

body.light-mode .bottom-nav {
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}

.nav-item.danger {
    color: #f87171;
}

.nav-item.danger svg {
    fill: currentColor;
}

.danger-btn {
    color: #f87171;
}

.panic-wrapper {
    padding: 12px 0 0 0;
}

.panic-btn {
    width: 100%;
    text-align: center;
    background: rgba(248, 113, 113, 0.12);
    color: #f87171;
    border: 1px solid rgba(248, 113, 113, 0.4);
    border-radius: 10px;
    padding: 12px;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.95rem;
}

.panic-btn:active {
    transform: scale(0.98);
    opacity: 0.9;
}

.refresh-wrapper {
    padding: 8px 0 0 0;
}

.refresh-btn {
    width: 100%;
    text-align: center;
    background: rgba(34, 197, 94, 0.12);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.4);
    border-radius: 10px;
    padding: 12px;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.95rem;
}

.refresh-btn:active {
    transform: scale(0.98);
    opacity: 0.9;
}

.refresh-btn:disabled {
    cursor: not-allowed;
    opacity: 0.55;
    color: var(--text-secondary);
    border-color: var(--border-color);
    background: rgba(125, 125, 125, 0.1);
}

.panic-overlay {
    position: fixed;
    inset: 0;
    background: rgba(220, 50, 50, 0.25);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 150;
}

.panic-overlay.active {
    opacity: 0;
    backdrop-filter: blur(0px);
}

.panic-overlay.beat {
    animation: panicBeat 0.35s ease;
}

@keyframes panicBeat {
    0%   { opacity: 0;    backdrop-filter: blur(0px); }
    25%  { opacity: 0.6;  backdrop-filter: blur(4px); }
    50%  { opacity: 0.25; backdrop-filter: blur(2px); }
    75%  { opacity: 0.1;  backdrop-filter: blur(1px); }
    100% { opacity: 0;    backdrop-filter: blur(0px); }
}

.refresh-overlay {
    position: fixed;
    inset: 0;
    background: rgba(34, 197, 94, 0.25);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 150;
}

.refresh-overlay.active {
    opacity: 0;
    backdrop-filter: blur(0px);
}

.refresh-overlay.beat {
    animation: refreshBeat 0.35s ease;
}

@keyframes refreshBeat {
    0%   { opacity: 0;    backdrop-filter: blur(0px); }
    25%  { opacity: 0.6;  backdrop-filter: blur(4px); }
    50%  { opacity: 0.25; backdrop-filter: blur(2px); }
    75%  { opacity: 0.1;  backdrop-filter: blur(1px); }
    100% { opacity: 0;    backdrop-filter: blur(0px); }
}

.faq-box {
    padding: 0 16px 16px 16px;
}

.faq-item {
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-top: 10px;
    padding: 10px 12px;
    transition: background-color 0.25s ease, border-color 0.25s ease;
}

.faq-item summary {
    cursor: pointer;
    font-weight: 700;
    color: var(--text-primary);
    outline: none;
    list-style: none;
    position: relative;
    padding-right: 20px;
}

.faq-item summary::-webkit-details-marker {
    display: none;
}

.faq-item summary::after {
    content: '›';
    position: absolute;
    right: 0;
    top: 0;
    font-size: 1rem;
    transform: rotate(0deg);
    transition: transform 0.2s ease;
}

.faq-item[open] summary::after {
    transform: rotate(90deg);
}

.faq-item div {
    margin-top: 8px;
    color: var(--text-secondary);
    line-height: 1.5;
    font-size: 0.9rem;
    transition: opacity 0.2s ease, max-height 0.2s ease;
}

.faq-item[open] {
    background: var(--surface-color);
    border-color: var(--border-color);
}

.toggle-btn {
    background: var(--input-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 8px 14px;
    border-radius: 10px;
    cursor: pointer;
    min-width: 100px;
    height: 38px;
    text-align: center;
}

.toggle-btn.active {
    background: var(--input-bg);
    color: #fff;
    border-color: var(--border-color);
}

body.light-mode .toggle-btn.active {
    color: var(--text-primary);
}
.chunk-wrapper {
    margin-top: 8px;
}

.chunk-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px 15px 12px 15px;
}

.chunk-item {
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.chunk-text {
    color: var(--accent-color);
    font-size: 0.9rem;
    word-break: break-word;
    flex: 1;
}

.chunk-copy {
    background: var(--btn-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 8px 10px;
    cursor: pointer;
}
.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-color);
}

.setting-row:last-child {
    border-bottom: none;
}

.setting-label {
    font-size: 0.95rem;
    color: var(--text-primary);
}

.setting-value {
    font-size: 0.9rem;
    color: var(--text-primary);
}

.status-box {
    margin-bottom: 12px;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    border: 1px solid var(--border-color);
    background: var(--input-bg);
    color: var(--text-secondary);
}

.status-badge::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 8px currentColor;
}

.status-badge.online {
    color: #22c55e;
    border-color: rgba(34, 197, 94, 0.45);
    background: rgba(34, 197, 94, 0.12);
}

.status-badge.offline {
    color: #f87171;
    border-color: rgba(248, 113, 113, 0.45);
    background: rgba(248, 113, 113, 0.12);
}

.status-badge.national {
    color: #9ca3af;
    border-color: rgba(148, 163, 184, 0.45);
    background: rgba(148, 163, 184, 0.12);
}

select {
    background: var(--input-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 0.85rem;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    text-align: center;
    min-width: 100px;
}

.page {
    display: none;
}

#page-settings,
#page-send {
    padding-bottom: 88px;
}

.page.active {
    display: block;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: var(--toast-bg);
    color: var(--toast-text);
    padding: 10px 24px;
    border-radius: 30px;
    font-size: 0.85rem;
    font-weight: bold;
    opacity: 0;
    pointer-events: none;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s;
    z-index: 400;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
    white-space: nowrap;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(50px);
}

.char-counter {
    padding: 0 15px 8px 15px;
    font-size: 0.85rem;
    color: #888;
}

[dir="rtl"] .char-counter { text-align: left; }
[dir="ltr"] .char-counter { text-align: right; }

.char-counter.grey { color: #888; }
.char-counter.orange { color: #fbbf24; }
.char-counter.red { color: #f87171; }

.warning-banner {
    background: rgba(255, 189, 46, 0.12);
    color: #ffbd2e;
    border: 1px solid rgba(255, 189, 46, 0.3);
    padding: 10px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    margin: 10px 15px 12px 15px;
    text-align: center;
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.update-banner {
    background: rgba(59, 130, 246, 0.12);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.35);
    padding: 10px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    margin: 10px 15px 12px 15px;
    text-align: center;
    line-height: 1.6;
    max-width: 100%;
    white-space: pre-line;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.alert-banner {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: rgba(59, 130, 246, 0.12);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.35);
    padding: 10px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    margin: 10px 15px 12px 15px;
    line-height: 1.6;
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.alert-message {
    flex: 1;
    white-space: pre-line;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.alert-dismiss {
    border: none;
    background: transparent;
    color: inherit;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    padding: 2px 6px;
}

.alert-dismiss:active {
    opacity: 0.7;
}

.lock-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    backdrop-filter: blur(6px);
}

.lock-card {
    background: var(--surface-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 16px;
    border-radius: 14px;
    width: 260px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-align: center;
}

.lock-card input {
    background: var(--input-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 8px 10px;
    border-radius: 10px;
    font-size: 0.95rem;
    text-align: center;
}

.lock-card button {
    background: var(--btn-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 10px;
    border-radius: 10px;
    cursor: pointer;
}

.pin-keypad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.pin-keypad button {
    border-radius: 50%;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    border: 1px solid var(--border-color);
    background: var(--input-bg);
    color: var(--text-primary);
    margin: 0 auto;
    cursor: pointer;
    transition: transform 0.1s ease, opacity 0.2s;
}

.pin-keypad .unlock-btn {
    background: var(--accent-color);
    color: #000;
}

.pin-keypad .unlock-btn svg {
    pointer-events: none;
}

.pin-keypad button:active {
    transform: scale(0.95);
    opacity: 0.8;
}

.lock-overlay.fade-out {
    animation: fadeOutBlur 0.25s forwards;
}

.lock-overlay.error-flash {
    animation: flashRed 0.4s;
}

@keyframes fadeOutBlur {
    from { opacity: 1; backdrop-filter: blur(6px); }
    to { opacity: 0; backdrop-filter: blur(0px); }
}

@keyframes flashRed {
    0% { background: rgba(0,0,0,0.6); backdrop-filter: blur(6px); }
    40% { background: rgba(255, 0, 0, 0.28); backdrop-filter: blur(9px); }
    80% { background: rgba(0,0,0,0.6); backdrop-filter: blur(6px); }
    100% { background: rgba(0,0,0,0.6); backdrop-filter: blur(6px); }
}

@media (min-width: 900px) {
    body {
        background-color: var(--desktop-bg-color);
    }

    body::after {
        content: '';
        position: fixed;
        top: 0;
        bottom: 0;
        left: 50%;
        width: var(--app-max-width);
        max-width: calc(100% - 40px);
        transform: translateX(-50%);
        background: var(--bg-color);
        border-radius: 24px 24px 0 0;
        box-shadow: none;
        z-index: 1;
        pointer-events: none;
    }

    header {
        width: var(--app-max-width);
        max-width: calc(100% - 40px);
        left: 50%;
        right: auto;
        transform: translateX(-50%);
    }

    main {
        width: var(--app-max-width);
        max-width: calc(100% - 40px);
        margin: 0 auto;
        position: relative;
        z-index: 2;
    }

    .bottom-nav {
        width: var(--app-max-width);
        max-width: calc(100% - 40px);
        left: 50%;
        right: auto;
        transform: translateX(-50%);
    }
}
