* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #000;
    color: #fff;
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100vh;
    height: -webkit-fill-available;
    touch-action: manipulation;
}

/* Schermo nero iniziale */
.black-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    height: -webkit-fill-available;
    background: #000;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.black-screen.active {
    opacity: 1;
    pointer-events: all;
}

/* Interfaccia principale */
.main-interface {
    display: flex;
    flex-direction: column-reverse;
    height: 100vh;
    height: -webkit-fill-available;
    background: #000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.main-interface.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Area risultati (ora in basso) */
.results-area {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 15px;
    padding-top: 15px;
    padding-bottom: calc(env(safe-area-inset-bottom) + 20px);
    -webkit-overflow-scrolling: touch;
    margin-top: calc(env(safe-area-inset-top) + 100px);
}

.results-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.result-item {
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 16px;
    line-height: 1.5;
    color: #fff;
}

.result-item:active {
    background: #2a2a2a;
    transform: scale(0.98);
}

.no-results {
    text-align: center;
    color: #666;
    padding: 40px 20px;
    font-size: 16px;
}

/* Textarea verde in alto */
.search-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 0;
    padding-top: env(safe-area-inset-top);
    background: #000;
    border-bottom: 2px solid #00ff00;
    z-index: 100;
}

.search-input {
    width: 100%;
    background: #003300;
    color: #00ff00;
    border: none;
    padding: 20px 15px;
    font-size: 18px;
    font-family: inherit;
    resize: none;
    outline: none;
    min-height: 80px;
    -webkit-appearance: none;
}

.search-input::placeholder {
    color: #006600;
}

/* Modale risposta corretta */
.answer-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    height: -webkit-fill-available;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
    padding-top: calc(env(safe-area-inset-top) + 20px);
    padding-bottom: calc(env(safe-area-inset-bottom) + 20px);
    opacity: 1;
    transition: opacity 0.3s ease;
}

.answer-modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.answer-content {
    background: #1a1a1a;
    border: 2px solid #00ff00;
    border-radius: 12px;
    padding: 30px;
    max-width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.answer-text {
    font-size: 20px;
    line-height: 1.6;
    color: #00ff00;
    text-align: center;
    word-wrap: break-word;
}

/* Pulsante impostazioni */
.settings-btn {
    position: fixed;
    bottom: calc(env(safe-area-inset-bottom) + 15px);
    right: 15px;
    width: 44px;
    height: 44px;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.settings-btn:active {
    background: #2a2a2a;
    transform: scale(0.95);
}

/* Pannello impostazioni */
.settings-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    height: -webkit-fill-available;
    background: rgba(0, 0, 0, 0.98);
    z-index: 10001;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 20px;
    padding-top: calc(env(safe-area-inset-top) + 20px);
    opacity: 1;
    transition: opacity 0.3s ease;
}

.settings-panel.hidden {
    opacity: 0;
    pointer-events: none;
}

.settings-content {
    max-width: 500px;
    margin: 0 auto;
}

.settings-content h2 {
    color: #00ff00;
    margin-bottom: 30px;
    text-align: center;
    font-size: 24px;
}

.settings-section {
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.settings-section h3 {
    color: #fff;
    margin-bottom: 15px;
    font-size: 18px;
}

.db-status, .storage-status {
    background: #0a0a0a;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 10px;
    font-size: 14px;
    line-height: 1.5;
    color: #999;
}

.file-input {
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    background: #0a0a0a;
    color: #fff;
    border: 1px solid #333;
    border-radius: 6px;
    font-size: 14px;
}

.btn {
    width: 100%;
    padding: 15px;
    background: #00ff00;
    color: #000;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    margin-bottom: 10px;
    transition: all 0.2s ease;
}

.btn:active {
    background: #00cc00;
    transform: scale(0.98);
}

.btn-danger {
    background: #ff3333;
    color: #fff;
}

.btn-danger:active {
    background: #cc0000;
}

.btn-close {
    background: #333;
    color: #fff;
    margin-top: 20px;
}

.btn-close:active {
    background: #444;
}

/* Scrollbar personalizzata per WebKit */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #0a0a0a;
}

::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #444;
}

