:root {
    --primary: #5c7cfa;
    --primary-dark: #3b5bdb;
    --primary-light: #748ffc;
    --secondary: #22b8cf;
    --bg-gradient-start: #82a8ff;
    --bg-gradient-end: #d0ebff;
    --surface: rgba(255, 255, 255, 0.7);
    --surface-hover: rgba(255, 255, 255, 0.9);
    --text-main: #212529;
    --text-muted: #495057;
    --border: rgba(255, 255, 255, 0.5);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.15);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-full: 9999px;
    --transition: all 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    color: var(--text-main);
    background: transparent; /* Transparent background for iframe */
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    -ms-user-select: none;
}

/* Smartphone Frame */
.smartphone-frame {
    width: 100%;
    max-width: 414px; /* iPhone Max width */
    height: 100vh;
    max-height: 896px;
    background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    z-index: 1;
}

.smartphone-frame::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: url('assets/wallpaperportrait.jpg') center/cover no-repeat;
    opacity: 0.3;
    z-index: -1;
}

@media (min-width: 450px) {
    .smartphone-frame {
        height: 90vh;
        border-radius: 36px;
        border: 12px solid #212529;
    }
}


.bg-logo svg {
    width: 100%;
    height: 100%;
}

/* Utilities */
.hidden { display: none !important; }
.glass-panel {
    background: rgba(255, 255, 255, 0.65);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
}
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-lg { box-shadow: var(--shadow-lg); }

/* Buttons */
button {
    font-family: inherit;
    border: none;
    background: transparent;
    cursor: pointer;
    transition: var(--transition);
}

.icon-btn {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.icon-btn:hover, .icon-btn:active {
    background: rgba(255, 255, 255, 0.2);
}

.btn-primary {
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-primary:hover, .btn-primary:active {
    background: var(--primary-dark);
    transform: scale(1.05);
}

.btn-primary.circle {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-full);
}

.btn-text {
    padding: 10px 16px;
    font-weight: 600;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
}

.btn-text:hover {
    background: rgba(0,0,0,0.05);
}

.btn-text.primary {
    color: var(--primary);
}

/* App Bar */
.app-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--primary);
    color: white;
    z-index: 100;
}

.title {
    font-size: 1.25rem;
    font-weight: 600;
    flex: 1;
    text-align: center;
}

/* Context Menu */
.context-menu {
    position: absolute;
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    padding: 8px 0;
    z-index: 1000;
    animation: fadeInScale 0.2s ease-out;
}

.menu-title {
    padding: 8px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.menu-item {
    width: 100%;
    text-align: left;
    padding: 12px 16px;
    font-size: 1rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 12px;
}

.menu-item .material-icons {
    font-size: 20px;
    color: var(--text-muted);
}

.menu-item:hover {
    background: rgba(0,0,0,0.04);
}

.text-danger {
    color: #ff6b6b;
}

.text-danger .material-icons {
    color: #ff6b6b;
}

hr {
    border: none;
    border-top: 1px solid #eee;
    margin: 8px 0;
}

/* Main Content */
#main-content {
    flex: 1;
    padding: 16px;
    padding-bottom: 100px; /* Space for bottom bar */
    overflow-y: auto;
    z-index: 1;
}

.word-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.word-item {
    background: rgba(255, 255, 255, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    padding: 16px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    animation: slideUp 0.3s ease-out backwards;
}

.word-item:hover {
    background: var(--surface-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.word-text {
    font-size: 1.1rem;
    font-weight: 500;
}

/* Bottom Bar */
.bottom-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    z-index: 100;
    background: linear-gradient(to top, rgba(255,255,255,0.8), transparent);
}

.rule-text {
    flex: 1;
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    font-size: 0.9rem;
    text-align: center;
    font-weight: 500;
    color: var(--primary-dark);
    box-shadow: var(--shadow-md);
    cursor: pointer;
    transition: var(--transition);
}

.rule-text:hover {
    transform: translateY(-2px);
}

/* Drawer */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 300;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.drawer {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    background: white;
    z-index: 400;
    display: flex;
    flex-direction: column;
    transform: translateX(0);
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.drawer.hidden {
    transform: translateX(-100%);
    display: flex !important; /* Override .hidden for animation */
}

.drawer-header {
    background: url('assets/wallpapernavigationdrawer.jpg') center/cover no-repeat;
    background-color: var(--primary); /* fallback */
    padding: 32px 16px 16px;
    color: white;
}

.drawer-title {
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 4px;
}

.drawer-link {
    color: rgba(255,255,255,0.8);
    font-size: 0.85rem;
    text-decoration: none;
}

.drawer-menu {
    list-style: none;
    padding: 8px 0;
    flex: 1;
}

.drawer-section {
    padding: 16px 16px 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
}

.drawer-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    color: var(--text-main);
    cursor: pointer;
    transition: var(--transition);
}

.drawer-item:hover {
    background: rgba(0,0,0,0.04);
}

.drawer-item.active {
    color: var(--primary);
    background: rgba(92, 124, 250, 0.1);
}

.drawer-footer {
    padding: 16px;
    display: flex;
    justify-content: flex-end;
}

.drawer-footer .icon-btn {
    color: var(--text-muted);
}

/* Dialog */
.dialog-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.dialog {
    background: white; /* Override glass-panel for better readability in dialogs */
    width: 100%;
    max-width: 400px;
    border-radius: var(--radius-md);
    overflow: hidden;
    animation: fadeInScale 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.dialog-title {
    padding: 20px 24px 12px;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary-dark);
}

.dialog-content {
    padding: 8px 24px;
}

.dialog-content.row {
    display: flex;
    gap: 24px;
    align-items: center;
}

/* Initials Inputs */
.initial-row {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
    margin-bottom: 16px;
}

.char-input {
    width: 48px;
    height: 48px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-dark);
    background: rgba(255,255,255,0.8);
    transition: var(--transition);
    text-transform: uppercase;
}

.char-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(92, 124, 250, 0.2);
}

.separator {
    font-size: 1.5rem;
    color: var(--text-muted);
}

/* Radio Buttons */
.radio-label {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    cursor: pointer;
    font-size: 0.95rem;
}

.radio-label input:checked + .radio-custom::after {
    content: '';
    width: 10px;
    height: 10px;
    background: var(--primary);
    border-radius: 50%;
}

.rule-summary {
    padding: 12px 24px;
    background: rgba(92, 124, 250, 0.1);
    color: var(--primary-dark);
    font-size: 0.9rem;
    font-weight: 500;
    margin-top: 16px;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 24px 16px;
}

/* Toast */
.toast {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius-full);
    font-weight: 500;
    z-index: 1000;
    transition: opacity 0.3s ease;
}

/* Animations */
@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.word-item {
    animation: slideIn 0.3s ease-out forwards;
    opacity: 0;
}

/* Settings UI Modernization */
.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    margin-bottom: 12px;
    background: rgba(0,0,0,0.02);
    border-radius: 12px;
    border: 1px solid rgba(0,0,0,0.05);
    transition: var(--transition);
}

.setting-item:hover {
    background: rgba(0,0,0,0.04);
}

.setting-label {
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--text-main);
    flex: 1;
}

.setting-select, .setting-input-text {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255,255,255,0.8);
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-main);
    outline: none;
    transition: var(--transition);
    min-width: 100px;
    text-align: right;
}

.setting-select:focus, .setting-input-text:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(92, 124, 250, 0.2);
}

.check-label {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.95rem;
}

/* Custom Toggle Switch for checkboxes */
.check-label input[type="checkbox"] {
    appearance: none;
    width: 44px;
    height: 24px;
    background: #ccc;
    border-radius: 12px;
    position: relative;
    cursor: pointer;
    outline: none;
    transition: var(--transition);
    flex-shrink: 0;
}

.check-label input[type="checkbox"]::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: var(--transition);
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.check-label input[type="checkbox"]:checked {
    background: var(--primary);
}

.check-label input[type="checkbox"]:checked::after {
    transform: translateX(20px);
}


/* Roller Picker for Initials */
.picker-container {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.5);
    padding: 8px;
    border-radius: var(--radius-md);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

.picker {
    height: 90px;
    width: 60px;
    position: relative;
    overflow: hidden;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.picker-list {
    height: 100%;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    padding: 30px 0; /* padding so top/bottom items can reach center */
    margin: 0;
    list-style: none;
}

.picker-list::-webkit-scrollbar {
    width: 14px;
    display: block;
}

.picker-list::-webkit-scrollbar-track {
    background: #f8f9fa;
    border-left: 1px solid #dee2e6;
}

.picker-list::-webkit-scrollbar-thumb {
    background: repeating-linear-gradient(
        0deg,
        #adb5bd,
        #adb5bd 2px,
        #ced4da 2px,
        #ced4da 4px
    );
    border-radius: 4px;
    border: 1px solid #868e96;
}

.picker-item {
    height: 30px;
    line-height: 30px;
    text-align: center;
    scroll-snap-align: center;
    font-size: 1.25rem;
    font-weight: 600;
    color: #ccc;
    transition: var(--transition);
    user-select: none;
}

.picker-item.selected {
    color: var(--primary);
    transform: scale(1.1);
}

.picker-window {
    position: absolute;
    top: 30px;
    height: 30px;
    width: 100%;
    border-top: 2px solid var(--primary-light);
    border-bottom: 2px solid var(--primary-light);
    pointer-events: none;
    background: rgba(92, 124, 250, 0.1);
}


.radio-label input {
    display: none;
}
.radio-custom {
    width: 20px;
    height: 20px;
    border: 2px solid var(--text-muted);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}
.radio-label input:checked + .radio-custom {
    border-color: var(--primary);
}

