:root {
    --bg-color: #f5f5f5;
    --chat-bg: white;
    --text-color: #333333;
    --message-user-bg: #e3f2fd;
    --message-assistant-bg: #f5f5f5;
    --message-system-bg: #fff3e0;
    --keyboard-bg: #e0e0e0;
    --key-bg: #ffffff;
    --key-border: #dddddd;
    --key-text: #333333;
    --input-bg: white;
    --input-border: #ddd;
    --settings-bg: #f0f0f0;
}

[data-theme="dark"] {
    --bg-color: #1a1a1a;
    --chat-bg: #2d2d2d;
    --text-color: #e0e0e0;
    --message-user-bg: #1e3a5f;
    --message-assistant-bg: #2d2d2d;
    --message-system-bg: #3d2d00;
    --keyboard-bg: #2d2d2d;
    --key-bg: #3d3d3d;
    --key-border: #4d4d4d;
    --key-text: #e0e0e0;
    --input-bg: #3d3d3d;
    --input-border: #4d4d4d;
    --settings-bg: #2d2d2d;
}

body {
    font-family: Arial, sans-serif;
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    background-color: var(--bg-color);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    color: var(--text-color);
}

#chat-container {
    background-color: var(--chat-bg);
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    flex: 1;
    overflow-y: auto;
    margin-bottom: 60px;
    margin-top: 20px;
}

.message {
    margin-bottom: 15px;
    padding: 10px;
    border-radius: 5px;
    line-height: 1.5;
}

.message p {
    margin: 0.5em 0;
}

.message pre {
    background-color: var(--input-bg);
    padding: 1em;
    border-radius: 4px;
    overflow-x: auto;
    border: 1px solid var(--input-border);
}

.message code {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    padding: 0.2em 0.4em;
    background-color: var(--input-bg);
    border-radius: 3px;
    font-size: 0.9em;
}

.message pre code {
    padding: 0;
    background-color: transparent;
}

.message ul, .message ol {
    margin: 0.5em 0;
    padding-left: 2em;
}

.message blockquote {
    border-left: 4px solid var(--input-border);
    margin: 0.5em 0;
    padding-left: 1em;
    color: var(--text-color);
}

.message h1, .message h2, .message h3, .message h4 {
    margin: 1em 0 0.5em 0;
    color: var(--text-color);
}

.user-message {
    background-color: var(--message-user-bg);
    margin-left: 20%;
}

.assistant-message {
    background-color: var(--message-assistant-bg);
    margin-right: 20%;
}

.system-message {
    background-color: var(--message-system-bg);
    margin: 10px 0;
    font-style: italic;
    color: #666;
}

#input-container {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 800px;
    padding: 10px;
    background: var(--chat-bg);
    box-shadow: 0 -2px 4px rgba(0,0,0,0.1);
    z-index: 1000;
    display: flex;
    gap: 10px;
    box-sizing: border-box;
}

#user-input {
    flex-grow: 1;
    padding: 10px;
    border: 1px solid var(--input-border);
    border-radius: 5px;
    font-size: 16px;
    background-color: var(--input-bg);
    color: var(--text-color);
}

button {
    padding: 10px 20px;
    background-color: #2196f3;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
}

.action-button {
    width: 50px;
    height: 50px;
    padding: 0;
    border-radius: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.action-button:hover {
    background-color: #1976d2;
    transform: scale(1.05);
}

.action-button:active {
    transform: scale(0.95);
}

.action-button:disabled {
    background-color: #bdbdbd;
    cursor: not-allowed;
    transform: none;
}

.button-icon {
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.button-icon i {
    transition: transform 0.2s ease;
}

.action-button:active .button-icon i {
    transform: scale(0.9);
}

.typing-indicator {
    color: #666;
    font-style: italic;
}

.settings-group {
    margin-bottom: 15px;
    padding: 10px;
    border-radius: 5px;
    background-color: var(--chat-bg);
    color: var(--text-color);
}

.settings-label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: var(--text-color);
}

.settings-value {
    color: var(--text-color);
    margin-left: 5px;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

input[type="range"] {
    flex-grow: 1;
    background-color: var(--chat-bg);
}

.keyboard-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--key-bg);
    border: 1px solid var(--key-border);
    color: var(--key-text);
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1002;
    padding: 0;
    transition: all 0.2s ease;
}

.keyboard-close:hover {
    background: #f5f5f5;
    border-color: #bbbbbb;
}

.keyboard-close:active {
    background: #e3f2fd;
    transform: scale(0.95);
    border-color: #2196f3;
}

.keyboard {
    position: fixed;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 800px;
    background: var(--keyboard-bg);
    padding: 10px;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    z-index: 1001;
    box-sizing: border-box;
}

.keyboard-row {
    display: flex;
    justify-content: center;
    margin-bottom: 5px;
}

.key {
    min-width: 40px;
    height: 40px;
    margin: 2px;
    border: none;
    border-radius: 5px;
    background: var(--key-bg);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    font-size: 18px;
    touch-action: manipulation;
    color: var(--key-text);
    font-weight: 500;
    border: 1px solid var(--key-border);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.1s ease;
}

.key:active {
    background: #e3f2fd;
    transform: translateY(2px);
    border-color: #2196f3;
}

.key:hover {
    background: #f5f5f5;
    border-color: #bbbbbb;
}

.key-wide {
    min-width: 80px;
}

.key-space {
    min-width: 200px;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    font-size: 14px;
    padding: 0 10px;
}

.key-space:hover {
    background-color: #e9ecef;
}

.key-space:active {
    background-color: #e3f2fd;
    transform: translateY(2px);
    border-color: #2196f3;
}

.shift-key.active {
    background-color: #2196f3;
    color: white;
}

.toggle-numbers {
    background-color: #f0f0f0;
}

.toggle-numbers:active {
    background-color: #e0e0e0;
}

#keyboard-container.hidden {
    display: none;
}

@media (max-width: 600px) {
    body {
        padding: 10px;
    }
    #input-container, .keyboard {
        padding: 10px;
        padding-right: 50px;
        width: 100%;
    }
}

.title{
    margin-top: 40px;
}

.header{
    display:flex;
    justify-content:space-between;
    align-items:center;

    height: 50px;                
    padding: 0 14px;
    flex-shrink:0;               

    background: var(--bg-color);  
    color:      var(--text-color);
    border-bottom: none;
    box-shadow: none;
}
.header-title{font-weight:600;font-size:1rem;}

.header .status-indicator{
    position:relative;
    top:auto; right:auto;         /* just to be safe */
    box-shadow:none;              /* optional: feels flatter in the bar */
}

/* === quick-action buttons (shared with the “?” button) -------------- */
.header .quick-actions{           /* extra selector so it wins specificity */
    position:relative;              /* reset the “fixed” positioning          */
    display:flex;
    gap:10px;
}

.status-indicator {
    position: fixed;
    top: 25px;
    right: 170px;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: var(--chat-bg);
    color: var(--text-color);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    z-index: 1002;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #4caf50;  /* Green for ready */
    transition: background-color 0.3s ease;
}

.status-dot.processing {
    background-color: #ff9800;  /* Orange for processing */
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.4; }
    100% { opacity: 1; }
}


/* The switch - the box around the slider */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

/* Hide default HTML checkbox */
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

/* The slider */
.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--input-border);
    transition: .4s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider {
    background-color: #2196F3;
}

input:checked + .slider:before {
    transform: translateX(26px);
}

/* Rounded sliders */
.slider.round {
    border-radius: 24px;
}

.slider.round:before {
    border-radius: 50%;
}

.theme-toggle-button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--chat-bg);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: var(--text-color);
}

.theme-icon {
    font-size: 20px;
}

.theme-icon.light::after {
    content: '☼';
}

.theme-icon.dark::after {
    content: '☾';
}

.theme-icon.light {
    display: none;
}

[data-theme="dark"] .theme-icon.light {
    display: block;
}

[data-theme="dark"] .theme-icon.dark {
    display: none;
}

.settings-summary {
    background: var(--chat-bg);
    color: var(--text-color);
}

.settings-panel {
    padding: 15px;
    border: 1px solid var(--input-border);
    border-radius: 5px;
    margin-top: 10px;
    background: var(--chat-bg);
    color: var(--text-color);
}

.settings-textarea {
    width: 100%;
    padding: 8px;
    border-radius: 4px;
    border: 1px solid var(--input-border);
    background-color: var(--input-bg);
    color: var(--text-color);
    resize: vertical;
}

.settings-select {
    width: 100%;
    padding: 8px;
    border-radius: 4px;
    border: 1px solid var(--input-border);
    background-color: var(--input-bg);
    color: var(--text-color);
    font-size: 14px;
    cursor: pointer;
}

.settings-select:hover {
    border-color: #2196f3;
}

.settings-select:focus {
    outline: none;
    border-color: #2196f3;
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2);
}

.settings-update-button {
    background-color: #4caf50;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
}

.settings-update-button:hover {
    background-color: #45a049;
}

.format-button {
    display: block;
    margin-top: 10px;
    padding: 5px 10px;
    background-color: var(--chat-bg);
    color: var(--text-color);
    border: 1px solid var(--input-border);
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.format-button:hover {
    background-color: var(--input-bg);
}

.response-wrapper {
    width: 100%;
}

.raw-content {
    white-space: pre-wrap;
    word-wrap: break-word;
}

.formatted-content {
    width: 100%;
}

.formatted-content pre {
    white-space: pre-wrap;
    word-wrap: break-word;
} 


/* TTS Toggle Button Container */
.tts-toggle-container {
    display: flex;
}

.tts-toggle-button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--chat-bg);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: var(--text-color);
    font-size: 12px;
    transition: background-color 0.2s ease;
}

.tts-toggle-button:hover {
    background: var(--input-bg);
}

/* Header that contains the "I'm reading..." text plus the button */
.references-header {
    background-color: #f8f9fa;  /* light grey background */
    padding: 1em;
    border-bottom: 1px solid #ddd;
    border-radius: 4px 4px 0 0; /* rounded top corners */
}
  
/* The area where streamed text goes, below the header */
.streaming-container {
    margin-top: 0;
    padding: 1em;
    background-color: #ffffff;
    border: 1px solid #ddd;
    border-radius: 0 0 4px 4px; /* rounded bottom corners */
}
  
/* The dropdown toggle button */
.references-dropdown-button {
    background-color: #007bff;
    color: #ffffff;
    padding: 8px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}
  
/* Slight hover effect */
.references-dropdown-button:hover {
    background-color: #0069d9;
}
  
/* The container that holds button + the actual dropdown menu */
.references-dropdown-container {
    margin-top: 1em;
    position: relative; /* so that if you switch to absolute positioning, it’s anchored here */
}
  
/* The dropdown menu itself */
.references-dropdown-content {
    display: none;
    background-color: #ffffff;
    margin-top: 0.5em;
    padding: 0.5em 1em;
    border: 1px solid #ddd;
    box-shadow: 0px 4px 8px rgba(0,0,0,0.1);
    border-radius: 4px;
    min-width: 200px;
    z-index: 100;
}
  
/* Links inside the dropdown */
.references-dropdown-content a {
    color: #333;
    text-decoration: none;
    display: block;
    padding: 8px 0;
    border-radius: 4px;
}
  
/* Hover effect for links */
.references-dropdown-content a:hover {
    background-color: #f2f2f2;
}
  
/* Show the dropdown when .open is toggled */
.references-dropdown-container.open .references-dropdown-content {
    display: block;
}
  
@media screen and (max-width: 800px) {
    .settings-panel {
        max-height: 300px; /* Adjust this value as needed */
        max-width: 90%;    /* Limit the panel's width relative to the viewport */
        overflow-y: auto;  /* Enable vertical scrolling if content overflows */
        margin: 10px auto; /* Center the panel and add vertical spacing */
    }
    
    .settings-summary {
        font-size: 14px;   /* Reduce font size for smaller screens */
        padding: 8px;      /* Decrease padding */
    }
}

.streaming-container,
.references-header {
    background-color: inherit;   /* matches dark/light theme */
    color: inherit;
}

.streaming-container {
    margin-top: 0;
    padding: 1em;
    background-color: inherit;   /* match the header’s colour */
    border: none;                /* remove grey outline */
    border-radius: 0;            /* square corners */
}


#history-toggle {
    display: flex; gap: .25rem; align-items: center;
    font-size: 0.9rem;
    cursor: pointer;
 }

.pdf-overlay {
    display: none;               /* hidden until we open it */
    position: fixed;
    top: 0; left: 0;
    width: 100vw;  height: 100vh;
    background: #fff;
    z-index: 9999;               /* on top of everything */
}
  
  .pdf-close-btn {
    position: absolute;
    top: 1rem;  right: 1rem;
    padding: 0.5em 1em;
    background: #007bff;
    color: #fff;
    border: none;
    border-radius: 0.25em;
    cursor: pointer;
    z-index: 10000;
}
  
  .pdf-iframe {
    width: 100%;
    height: 100%;
}

  /* make sure this comes *after* your existing rules */
.pdf-close-btn {
    position: absolute;
    top: 50px;       /* push it down so it doesn’t overlap the browser’s titlebar */
    right: 20px;     /* give it a little breathing room from the edge */
    padding: 0.5em 1em;
    border-radius: 4px;
    z-index: 10000;  /* on top of the iframe */
    /* optional drop‑shadow so it “floats” above the PDF toolbar */
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}


/* === quick-action buttons (shared with the “?” button) -------------- */
.quick-actions{
    position:fixed; top:20px; right:20px;
    display:flex; gap:10px;
    z-index:1010;
}

.qa-btn{
    width:40px;height:40px;border:none;border-radius:50%;
    background:var(--chat-bg);color:var(--text-color);
    display:flex;align-items:center;justify-content:center;
    box-shadow:0 2px 4px rgba(0,0,0,.12);cursor:pointer;
    transition:background-color .2s,transform .2s;
}
.qa-btn:hover   { background:var(--input-bg); transform:translateY(-1px); }
.qa-btn:disabled{ opacity:.5; cursor:not-allowed; }

/* --- hamburger & dropdown ---------------------------------------- */
.menu{ position:relative; }      /* <-- only this rule remains */

.menu-dropdown{
    position:absolute;top:48px;right:0;
    display:none;flex-direction:column;gap:10px;min-width:230px;
    padding:12px 14px;border-radius:10px;
    background:var(--chat-bg);box-shadow:0 4px 12px rgba(0,0,0,.14);
}
.menu-dropdown.show{display:flex;}

.menu-item{font-size:.9rem;display:flex;align-items:center;gap:8px;}
.menu-item input{transform:translateY(1px);}
.linklike{
    background:none;border:none;padding:0;font:inherit;text-align:left;
    color:var(--text-color);cursor:pointer;
}
[data-theme="dark"] .menu-dropdown{box-shadow:0 4px 12px rgba(0,0,0,.5);}

/* modal shell */
.settings-modal{ border:0; padding:0; background:transparent; }
.settings-modal::backdrop{ background:rgba(0,0,0,.45); }

/* inner card uses existing .settings-panel colours */
.settings-panel{
    width:min(90vw,520px);
    max-height:80vh;
    overflow:auto;
    border-radius:10px;
    margin:0;
}

/* close “×” button */
.modal-close{
    position:absolute; top:12px; right:16px;
    border:none; background:none; font-size:1.6rem;
    cursor:pointer; color:var(--text-color);
}

.memory-banner{
    margin:20px 0;
    padding:12px 16px;
    border-radius:8px;
    background:var(--chat-bg);
    color:var(--text-color);
    box-shadow:0 2px 6px rgba(0,0,0,.12);
    display:flex; align-items:center; gap:14px;
    position:relative;
}
.memory-banner .banner-close{
    position:absolute; top:6px; right:8px;
    border:none; background:none; font-size:1.2rem;
    cursor:pointer; color:var(--text-color);
}
.memory-radio{display:flex; align-items:center; gap:6px; cursor:pointer;}
.memory-radio input{display:none;}
.fake-radio{
    width:14px; height:14px; border-radius:50%;
    border:2px solid var(--text-color);
    display:inline-block;
}
.memory-radio input:checked + .fake-radio{
    background:var(--text-color);
}
.memory-banner[hidden] { display:none !important; }


/* UPDATE BEGIN ── Wi-Fi list */
.wifi-list{list-style:none;padding:0;margin:0 0 12px 0;max-height:45vh;overflow:auto}
.wifi-list li{padding:6px 8px;border-radius:6px;cursor:pointer}
.wifi-list li:hover{background:var(--accent-bg,rgba(0,0,0,.08))}
.wifi-list .error{color:var(--error-color,crimson);cursor:default}
/* UPDATE END */

.modal-close{
    position:absolute;
    top:8px;              
    right:12px;
    font-size:1.3rem;
    line-height:1;        /* keep it square */
    background:none;
    border:0;
    color:var(--text-color);
    cursor:pointer;
}
.modal-close:hover{opacity:.75}

.update-btn-row {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
}

#start-update.primary {
  font-size: 1.05rem;
  padding: 0.6rem 1.4rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  margin-left: auto;
}

#start-update.primary:disabled {
  opacity: .5;
  cursor: not-allowed;
}

#log-box {
  white-space: pre-wrap;
  font-family: monospace;
  background: #fafafa;
  color: #333;
  border: 1px solid #444;
  padding: .75rem;
  max-height: 40vh;
  overflow-y: auto;
  margin-top: .75rem;
}