:root {
    --background: 0 0% 100%;
    --foreground: 222.2 84% 4.9%;
    --card: 0 0% 100%;
    --card-foreground: 222.2 84% 4.9%;
    --primary: 222.2 47.4% 11.2%;
    --primary-foreground: 210 40% 98%;
    --secondary: 210 40% 96.1%;
    --secondary-foreground: 222.2 47.4% 11.2%;
    --muted: 210 40% 96.1%;
    --muted-foreground: 215.4 16.3% 46.9%;
    --accent: 210 40% 96.1%;
    --accent-foreground: 222.2 47.4% 11.2%;
    --border: 214.3 31.8% 91.4%;
    --input: 214.3 31.8% 91.4%;
    --ring: 222.2 84% 4.9%;
    --radius: 0.5rem;
    --popover: 0 0% 100%;
    --popover-foreground: 222.2 84% 4.9%;
    --destructive: 0 72% 51%;
    --destructive-foreground: 210 40% 98%;
}

*, *::before, *::after { box-sizing: border-box; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

.imeselector { display: none !important; }

.page {
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    font-family: "Plus Jakarta Sans", system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    margin: 0;
}

.nav {
    border-bottom: 1px solid hsl(var(--border));
    background: hsl(var(--background));
    position: sticky;
    top: 0;
    z-index: 40;
}

.nav-inner {
    max-width: 64rem;
    margin: 0 auto;
    padding: 0 1rem;
    height: 3.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo-text {
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: -0.025em;
}

.main {
    flex: 1;
    width: 100%;
    max-width: 64rem;
    margin: 0 auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.toolbar {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    justify-content: space-between;
    align-items: stretch;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    width: 100%;
}

.btn, .btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    border: 1px solid hsl(var(--input));
    transition: background 0.15s, color 0.15s;
    height: 2.25rem;
    min-height: 44px;
    min-width: 44px;
    touch-action: manipulation;
    user-select: none;
    cursor: pointer;
    font-family: inherit;
    line-height: 1;
    gap: 0.375rem;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}
.btn { padding: 0 0.75rem; width: 100%; }
.btn-icon { padding: 0; width: 2.25rem; }

.btn:hover, .btn-icon:hover {
    background: hsl(var(--accent));
    color: hsl(var(--accent-foreground));
}

.btn:focus-visible, .btn-icon:focus-visible {
    outline: 2px solid hsl(var(--ring));
    outline-offset: 2px;
}

.btn:active, .btn-icon:active {
    transform: scale(0.98);
}

.btn-secondary {
    background: hsl(var(--secondary));
    color: hsl(var(--secondary-foreground));
    border-color: hsl(var(--border));
}
.btn-secondary:hover {
    background: hsl(var(--accent));
    color: hsl(var(--accent-foreground));
}

.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: hsl(var(--foreground));
}
.btn-ghost:hover {
    background: hsl(var(--accent));
    color: hsl(var(--accent-foreground));
}

.btn-destructive {
    background: hsl(var(--destructive));
    color: hsl(var(--destructive-foreground));
    border-color: hsl(var(--destructive));
}
.btn-destructive:hover {
    background: hsl(var(--destructive) / 0.9);
}

.btn-label { display: none; }
.icon { opacity: 0.9; }

.counter {
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
    margin-left: 0.25rem;
    display: none;
}

.editor {
    position: relative;
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#banglapad {
    width: 100%;
    border-radius: var(--radius);
    border: 1px solid hsl(var(--input));
    background: hsl(var(--background));
    padding: 0.75rem 1rem;
    font-size: 1.125rem;
    font-family: "Noto Sans Bengali", system-ui, sans-serif;
    resize: vertical;
    min-height: 120px;
    flex: 1;
    color: hsl(var(--foreground));
    line-height: 1.5;
    box-sizing: border-box;
}
#banglapad::placeholder {
    color: hsl(var(--muted-foreground));
}
#banglapad:focus-visible {
    outline: 2px solid hsl(var(--ring));
    outline-offset: 2px;
}
#banglapad:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.layout-box {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: hsl(var(--card));
    border-radius: var(--radius);
    border: 1px solid hsl(var(--input));
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
}

#layout-container {
    transition: opacity 0.15s ease;
    transform-origin: top center;
}
#layout-container.state-hidden {
    opacity: 0;
    pointer-events: none;
}
#layout-container.state-visible {
    opacity: 1;
    pointer-events: auto;
}

.layout-img-wrap {
    display: flex;
    justify-content: center;
    overflow-x: auto;
}

.layout-img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
    border: 1px solid hsl(var(--border));
}

#action-layout { position: relative; }
#action-layout.active {
    background: hsl(var(--accent));
    color: hsl(var(--accent-foreground));
}
#action-layout .shortcut-tip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    padding: 3px 7px;
    background: hsl(var(--foreground));
    color: hsl(var(--background));
    font-size: 10px;
    border-radius: 3px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.1s ease, transform 0.1s ease;
    z-index: 10;
}
#action-layout:hover .shortcut-tip {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

#copy-toast {
    position: fixed;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.75rem;
    background: hsl(var(--foreground));
    color: hsl(var(--background));
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}
#copy-toast.hidden { display: none; }

.hidden { display: none; }

@media (min-width: 640px) {
    .nav-inner { padding-left: 1.5rem; padding-right: 1.5rem; }
    .main { padding: 1.5rem; }
    .toolbar { flex-direction: row; align-items: center; gap: 0.75rem; }
    .toolbar-group { width: auto; }
    .btn { width: auto; }
    .btn-label { display: inline; }
    .counter { display: inline; margin-left: 0.5rem; }
}

.back-btn {
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 50;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 9999px;
    background: hsl(var(--background));
    border: 1px solid hsl(var(--border));
    color: hsl(var(--foreground));
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}
.back-btn:hover {
    background: hsl(var(--accent));
    color: hsl(var(--accent-foreground));
}
.back-btn:focus-visible {
    outline: 2px solid hsl(var(--ring));
    outline-offset: 2px;
}

.practice-content {
    padding-top: 4rem;
}

.practice-select {
    width: 100%;
    height: 2.25rem;
    padding: 0 0.75rem;
    border-radius: var(--radius);
    border: 1px solid hsl(var(--input));
    background: hsl(var(--background));
    font-family: "Noto Sans Bengali", system-ui, sans-serif;
    font-size: 0.875rem;
    cursor: pointer;
    color: hsl(var(--foreground));
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
}
.practice-select:focus-visible {
    outline: 2px solid hsl(var(--ring));
    outline-offset: 2px;
}

.practice-reference {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    border: 1px solid hsl(var(--border));
    background: hsl(var(--muted));
    font-family: "Noto Sans Bengali", system-ui, sans-serif;
    font-size: 1rem;
    line-height: 1.7;
    user-select: none;
    pointer-events: none;
    color: hsl(var(--foreground));
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
}

.practice-content .layout-box {
    margin-top: 0;
}

.mobile-unavailable {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
    text-align: center;
    gap: 1rem;
}

@media (max-width: 767px) {
    #action-layout .shortcut-tip { display: none; }
    .practice-content { display: none; }
    .mobile-unavailable { display: flex; }
    .back-btn { display: none; }
}

@media (min-width: 1024px) {
    .nav-inner { padding-left: 2rem; padding-right: 2rem; }
    .main { padding-left: 2rem; padding-right: 2rem; }
}
