* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    min-height: 100vh;
    color: #e8e8e8;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

h1 {
    font-size: 2.5rem;
    color: #fff;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: #c4a747;
    font-size: 1.1rem;
}

main {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 2rem;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 0.5rem;
}

.tab {
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px 8px 0 0;
    color: #888;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.tab:hover {
    color: #c4a747;
}

.tab.active {
    background: rgba(196, 167, 71, 0.1);
    border-color: rgba(196, 167, 71, 0.3);
    border-bottom-color: transparent;
    color: #c4a747;
    margin-bottom: -1px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* File upload */
.file-upload {
    position: relative;
}

.file-upload input[type="file"] {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

.file-upload-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    border: 2px dashed rgba(196, 167, 71, 0.3);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
    transition: all 0.2s;
}

.file-upload:hover .file-upload-label {
    border-color: #c4a747;
    background: rgba(196, 167, 71, 0.05);
}

.file-upload-label.has-file {
    border-style: solid;
    border-color: #c4a747;
    background: rgba(196, 167, 71, 0.1);
}

.file-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.file-text {
    color: #888;
    font-size: 0.9rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #c8c8c8;
}

textarea {
    width: 100%;
    padding: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    font-size: 1rem;
    resize: vertical;
    transition: border-color 0.3s;
}

textarea:focus {
    outline: none;
    border-color: #c4a747;
}

textarea::placeholder {
    color: #888;
}

/* Voice input */
.textarea-wrapper {
    position: relative;
}

.textarea-wrapper textarea {
    padding-right: 55px;
}

.voice-btn {
    position: absolute;
    right: 10px;
    top: 10px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid rgba(196, 167, 71, 0.3);
    background: rgba(196, 167, 71, 0.1);
    color: #c4a747;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.voice-btn:hover {
    background: rgba(196, 167, 71, 0.2);
    border-color: #c4a747;
}

.voice-btn.recording {
    background: rgba(220, 53, 69, 0.2);
    border-color: #dc3545;
    animation: pulse 1s infinite;
}

.voice-btn.recording .voice-icon {
    display: none;
}

.voice-btn.recording .voice-stop {
    display: block !important;
}

.voice-btn.transcribing {
    opacity: 0.6;
    cursor: wait;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Voice input area (new design) */
.label-hint {
    font-weight: 400;
    color: #888;
    font-size: 0.85rem;
}

.voice-input-area {
    display: flex;
    gap: 1rem;
    align-items: stretch;
}

.voice-input-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    border: 2px dashed rgba(196, 167, 71, 0.3);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.02);
    min-width: 100px;
    transition: all 0.2s;
}

.voice-input-box:hover {
    border-color: #c4a747;
    background: rgba(196, 167, 71, 0.05);
}

.voice-input-box.recording {
    border-color: #dc3545;
    background: rgba(220, 53, 69, 0.1);
}

.voice-btn-large {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 2px solid rgba(196, 167, 71, 0.5);
    background: rgba(196, 167, 71, 0.15);
    color: #c4a747;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
}

.voice-btn-large:hover {
    background: rgba(196, 167, 71, 0.25);
    border-color: #c4a747;
    transform: scale(1.05);
}

.voice-btn-large.recording {
    background: rgba(220, 53, 69, 0.25);
    border-color: #dc3545;
    animation: pulse 1s infinite;
}

.voice-btn-large.recording .voice-icon {
    display: none;
}

.voice-btn-large.recording .voice-stop {
    display: block !important;
}

.voice-hint {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: #888;
    text-align: center;
}

.voice-input-area textarea {
    flex: 1;
}

/* Final prompt section */
.final-prompt-group {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: rgba(196, 167, 71, 0.05);
    border: 1px solid rgba(196, 167, 71, 0.2);
    border-radius: 8px;
}

.final-prompt-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0;
}

.final-prompt-header label {
    margin-bottom: 0;
    color: #c4a747;
}

.toggle-btn {
    padding: 0.4rem 0.8rem;
    background: transparent;
    border: 1px solid rgba(196, 167, 71, 0.3);
    border-radius: 4px;
    color: #c4a747;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.toggle-btn:hover {
    background: rgba(196, 167, 71, 0.1);
}

.toggle-btn .toggle-icon {
    display: inline-block;
    transition: transform 0.2s;
}

.toggle-btn.expanded .toggle-icon {
    transform: rotate(180deg);
}

.final-prompt-content {
    margin-top: 1rem;
}

.final-prompt-content textarea {
    background: rgba(0, 0, 0, 0.2);
    border-color: rgba(196, 167, 71, 0.3);
}

.prompt-status {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: #888;
}

.prompt-status.refined {
    color: #4caf50;
}

.prompt-status.fallback {
    color: #ff9800;
}

.hints {
    margin-top: 0.75rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.hints-label {
    font-size: 0.85rem;
    color: #888;
    width: 100%;
    margin-bottom: 0.5rem;
}

.hint-btn {
    padding: 0.5rem 1rem;
    background: rgba(196, 167, 71, 0.1);
    border: 1px solid rgba(196, 167, 71, 0.3);
    border-radius: 8px;
    color: #c4a747;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    line-height: 1.4;
    flex: 1 1 100%;
}

.hint-btn:hover {
    background: rgba(196, 167, 71, 0.2);
    border-color: #c4a747;
}

input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
    margin: 10px 0;
    position: relative;
    z-index: 10;
}

input[type="range"]::-webkit-slider-runnable-track {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #c4a747;
    cursor: pointer;
    margin-top: -6px;
}

input[type="range"]::-moz-range-track {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #c4a747;
    cursor: pointer;
    border: none;
}

.temp-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: #888;
}

.model-desc {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: #888;
    min-height: 1.2em;
}

/* Model selector buttons */
.model-selector {
    display: flex;
    gap: 0.5rem;
}

.model-btn {
    flex: 1;
    padding: 0.9rem 1.5rem;
    background: transparent;
    border: 1px solid rgba(196, 167, 71, 0.25);
    border-radius: 8px;
    color: #888;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.model-btn:hover:not(:disabled) {
    background: rgba(196, 167, 71, 0.08);
    border-color: rgba(196, 167, 71, 0.5);
    color: #c4a747;
}

.model-btn.active {
    background: linear-gradient(135deg, rgba(196, 167, 71, 0.15) 0%, rgba(139, 117, 48, 0.15) 100%);
    border-color: #c4a747;
    color: #c4a747;
}

.model-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.model-btn .model-name {
    font-weight: 600;
    font-size: 1.05rem;
    display: block;
}

.model-btn .model-base {
    font-size: 0.75rem;
    opacity: 0.6;
    display: block;
    margin-top: 0.2rem;
}

.model-btn .model-status {
    font-size: 0.7rem;
    color: #dc3545;
    display: block;
    margin-top: 0.2rem;
}

.btn-primary {
    width: 100%;
    padding: 1rem 2rem;
    background: linear-gradient(135deg, #c4a747 0%, #8b7530 100%);
    border: none;
    border-radius: 8px;
    color: #fff;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(196, 167, 71, 0.3);
}

.btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-secondary {
    padding: 0.6rem 1.2rem;
    background: transparent;
    border: 1px solid #c4a747;
    border-radius: 6px;
    color: #c4a747;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: rgba(196, 167, 71, 0.2);
}

.btn-danger {
    border-color: #dc3545;
    color: #dc3545;
}

.btn-danger:hover {
    background: rgba(220, 53, 69, 0.2);
}

.loader {
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.hidden {
    display: none !important;
}

.result {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.result-header h2 {
    font-size: 1.3rem;
    color: #c4a747;
}

.result-text {
    background: rgba(0, 0, 0, 0.2);
    padding: 1.5rem;
    border-radius: 8px;
    line-height: 1.7;
    white-space: pre-wrap;
    font-size: 1rem;
}

/* Progress */
.progress {
    margin-top: 1.5rem;
    padding: 1rem;
    background: rgba(196, 167, 71, 0.1);
    border: 1px solid rgba(196, 167, 71, 0.3);
    border-radius: 8px;
}

.progress-text {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    color: #c4a747;
}

.progress-bar {
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #c4a747, #e8d78a);
    border-radius: 3px;
    transition: width 0.1s ease;
}

.rag-info {
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: #888;
}

.rag-label {
    color: #c4a747;
}

.rag-titles {
    font-style: italic;
}

.url-sources-info,
.web-search-info {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: #888;
}

.web-search-list {
    font-style: italic;
}

.url-sources-list {
    font-style: italic;
}

.url-source-link {
    color: #88c0d0;
    text-decoration: none;
    transition: color 0.2s;
}

.url-source-link:hover {
    color: #c4a747;
    text-decoration: underline;
}

.url-source-failed {
    color: #dc3545;
    font-size: 0.8rem;
    background: rgba(220, 53, 69, 0.1);
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    cursor: help;
}

.url-hint {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: #666;
    font-style: italic;
}

/* Error */
.error {
    margin-top: 1.5rem;
    padding: 1.25rem;
    background: rgba(220, 53, 69, 0.15);
    border: 1px solid rgba(220, 53, 69, 0.4);
    border-radius: 8px;
}

.error-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.error-icon {
    font-size: 1.2rem;
}

.error-code {
    font-weight: 600;
    color: #ff6b6b;
    font-family: monospace;
}

.error-message {
    color: #f8d7da;
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.error-details {
    color: #aaa;
    font-size: 0.85rem;
    font-family: monospace;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.5rem;
    border-radius: 4px;
    margin-top: 0.5rem;
}

/* Result stats */
.result-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.result-stats {
    font-size: 0.85rem;
    color: #888;
}

footer {
    margin-top: 2rem;
    text-align: center;
    color: #666;
    font-size: 0.85rem;
}

footer code {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    color: #c4a747;
}

.footer-model {
    margin-bottom: 0.75rem;
}

.footer-about {
    font-size: 0.8rem;
    line-height: 1.6;
    color: #555;
}

.footer-about a {
    color: #c4a747;
    text-decoration: none;
}

.footer-about a:hover {
    text-decoration: underline;
}

.footer-about strong {
    color: #888;
}

/* Articles tab */
.search-box {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.search-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    font-size: 1rem;
}

.search-input:focus {
    outline: none;
    border-color: #c4a747;
}

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

.articles-info {
    font-size: 0.9rem;
    color: #888;
    margin-bottom: 1.5rem;
}

.articles-info span {
    color: #c4a747;
    font-weight: 600;
}

.articles-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.article-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 1.25rem;
    cursor: pointer;
    transition: all 0.2s;
}

.article-card:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(196, 167, 71, 0.4);
    transform: translateX(4px);
}

.article-card-header {
    display: flex;
    align-items: flex-start;
    margin-bottom: 0.75rem;
    gap: 0.75rem;
}

.article-num {
    font-size: 0.75rem;
    font-weight: 600;
    color: #c4a747;
    background: rgba(196, 167, 71, 0.15);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    white-space: nowrap;
}

.article-title {
    font-size: 1.05rem;
    font-weight: 500;
    color: #e8e8e8;
    flex: 1;
    line-height: 1.4;
}

.article-score {
    background: rgba(196, 167, 71, 0.2);
    color: #c4a747;
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    white-space: nowrap;
}

.article-meta {
    font-size: 0.8rem;
    color: #888;
    margin-bottom: 0.5rem;
}

.article-preview {
    font-size: 0.9rem;
    color: #aaa;
    line-height: 1.6;
    max-height: 4.8em;
    overflow: hidden;
}

.article-tags {
    margin-top: 0.75rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.article-tag {
    background: rgba(255, 255, 255, 0.05);
    color: #888;
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 1.5rem;
    padding: 1rem;
}

.pagination-info {
    color: #888;
    font-size: 0.9rem;
}

.pagination-btn {
    min-width: 100px;
}

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

#searchStatus {
    color: #c4a747;
    font-style: italic;
}

/* History tab */
.history-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: rgba(196, 167, 71, 0.1);
    border: 1px solid rgba(196, 167, 71, 0.2);
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 1.8rem;
    font-weight: 600;
    color: #c4a747;
}

.stat-label {
    font-size: 0.85rem;
    color: #888;
}

.history-section {
    margin-bottom: 2rem;
}

.history-section h3 {
    font-size: 1.1rem;
    color: #c4a747;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.history-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(196, 167, 71, 0.3);
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.history-item-prompt {
    font-size: 0.95rem;
    color: #e8e8e8;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-right: 1rem;
}

.history-item-date {
    font-size: 0.8rem;
    color: #666;
    white-space: nowrap;
}

.history-item-meta {
    font-size: 0.8rem;
    color: #888;
}

.history-item-preview {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: #aaa;
    line-height: 1.5;
    max-height: 3em;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-empty {
    text-align: center;
    color: #666;
    padding: 2rem;
    font-style: italic;
}

/* History modal */
.history-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.history-modal-content {
    background: #1a1a2e;
    border: 1px solid rgba(196, 167, 71, 0.3);
    border-radius: 12px;
    max-width: 800px;
    width: 100%;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.history-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.history-modal-header h3 {
    color: #c4a747;
    margin: 0;
}

.history-modal-close {
    background: none;
    border: none;
    color: #888;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.history-modal-close:hover {
    color: #fff;
}

.history-modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.history-modal-body pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: inherit;
    margin: 0;
    line-height: 1.6;
}

.full-prompt-details {
    margin-bottom: 1rem;
    border: 1px solid rgba(196, 167, 71, 0.3);
    border-radius: 6px;
    overflow: hidden;
}

.full-prompt-details summary {
    padding: 0.75rem 1rem;
    background: rgba(196, 167, 71, 0.1);
    cursor: pointer;
    font-size: 0.9rem;
    color: #c4a747;
}

.full-prompt-details summary:hover {
    background: rgba(196, 167, 71, 0.2);
}

.full-prompt-pre {
    max-height: 300px;
    overflow-y: auto;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.3);
    font-size: 0.85rem;
    color: #aaa;
}

.history-modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

@media (max-width: 600px) {
    .container {
        padding: 1rem;
    }

    h1 {
        font-size: 1.8rem;
    }

    main {
        padding: 1.5rem;
    }

    .hints {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Web search button */
.web-search-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    padding: 1rem 1.5rem;
    background: rgba(255, 255, 255, 0.03);
    border: 2px dashed rgba(196, 167, 71, 0.3);
    border-radius: 12px;
    color: #c8c8c8;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.web-search-btn:hover:not(:disabled) {
    background: rgba(196, 167, 71, 0.1);
    border-color: #c4a747;
    color: #c4a747;
}

.web-search-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.web-search-btn-icon {
    font-size: 1.3rem;
}

.web-search-btn-text {
    font-size: 1rem;
}

/* Web search result badge */
.web-search-result {
    background: rgba(76, 175, 80, 0.1);
    border: 1px solid rgba(76, 175, 80, 0.3);
    border-radius: 10px;
    padding: 0.75rem 1rem;
}

.web-search-result-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.web-search-result-icon {
    color: #4caf50;
    font-size: 1.1rem;
}

.web-search-result-title {
    color: #4caf50;
    font-weight: 500;
    flex: 1;
}

.web-search-result-clear {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    font-size: 1rem;
    padding: 0.25rem;
    line-height: 1;
    transition: color 0.2s;
}

.web-search-result-clear:hover {
    color: #e57373;
}

.web-search-result-preview {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: #aaa;
    line-height: 1.5;
}

.web-search-result-expand {
    background: none;
    border: none;
    color: #4caf50;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0.25rem 0.5rem;
    transition: color 0.2s;
}

.web-search-result-expand:hover {
    color: #c4a747;
}

.web-search-result-full {
    margin-top: 0.75rem;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 6px;
    font-size: 0.95rem;
    color: #e0e0e0;
    line-height: 1.6;
    max-height: 300px;
    overflow-y: auto;
}

/* Facts modal - large and readable */
.modal-facts {
    max-width: 700px;
    width: 95%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    text-align: left;
}

.modal-facts-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-facts-header .modal-icon {
    font-size: 2rem;
    margin: 0;
}

.modal-facts-header .modal-title {
    margin: 0;
    font-size: 1.2rem;
}

.facts-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 3rem;
    color: #888;
    font-size: 1.1rem;
}

.facts-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(196, 167, 71, 0.2);
    border-top-color: #c4a747;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.facts-content {
    background: rgba(0, 0, 0, 0.25);
    border-radius: 8px;
    padding: 1.25rem;
    max-height: 40vh;
    overflow-y: auto;
    margin-bottom: 1rem;
}

.facts-text {
    color: #e8e8e8;
    font-size: 1rem;
    line-height: 1.7;
}

.facts-error {
    color: #e57373;
    text-align: center;
    padding: 2rem;
    font-size: 1.1rem;
}

/* Sources section - always visible below content */
.facts-sources-section {
    background: rgba(196, 167, 71, 0.08);
    border: 1px solid rgba(196, 167, 71, 0.2);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.facts-sources-section .facts-sources-header {
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(196, 167, 71, 0.2);
}

.facts-sources-section .checkbox-label {
    font-size: 0.95rem;
    color: #c4a747;
    font-weight: 500;
}

.facts-sources-section .facts-sources-list {
    max-height: 150px;
    overflow-y: auto;
}

.modal-buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

.modal-btn-secondary {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #888;
}

.modal-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.3);
    color: #c8c8c8;
    transform: none;
    box-shadow: none;
}

.modal-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Hidden utility class (keep for compatibility) */
.source-urls-toggle {
    margin-bottom: 0.5rem;
}

.link-btn {
    background: none;
    border: none;
    color: #888;
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0.25rem 0;
    transition: color 0.2s;
}

.link-btn:hover {
    color: #c4a747;
}

.source-urls-section {
    margin-top: 0.5rem;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
}

/* Source URLs list */
.source-urls-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.source-url-input {
    padding: 0.6rem 1rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.3);
    color: #e8e8e8;
    font-size: 0.9rem;
}

.source-url-input:focus {
    outline: none;
    border-color: #c4a747;
}

.source-url-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

/* Reference article chip */
.reference-article-group {
    margin-top: 0.5rem;
}

.reference-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(196, 167, 71, 0.2);
    border: 1px solid rgba(196, 167, 71, 0.5);
    border-radius: 20px;
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    color: #c4a747;
}

.reference-title {
    max-width: 400px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reference-remove {
    background: none;
    border: none;
    color: #c4a747;
    cursor: pointer;
    padding: 0;
    font-size: 1rem;
    line-height: 1;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.reference-remove:hover {
    opacity: 1;
}

/* Indeterminate progress bar animation */
@keyframes indeterminate {
    0% {
        left: -30%;
        width: 30%;
    }
    50% {
        left: 50%;
        width: 30%;
    }
    100% {
        left: 100%;
        width: 30%;
    }
}

.progress-fill.indeterminate {
    position: absolute;
    width: 30% !important;
    animation: indeterminate 1.5s ease-in-out infinite;
}

.progress-bar {
    position: relative;
    overflow: hidden;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-overlay.hidden {
    display: none;
}

.modal-content {
    background: linear-gradient(135deg, #2a2520 0%, #1a1815 100%);
    border: 1px solid rgba(196, 167, 71, 0.3);
    border-radius: 16px;
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.modal-title {
    font-size: 1.4rem;
    font-weight: 600;
    color: #c4a747;
    margin-bottom: 1rem;
}

.modal-message {
    font-size: 1.1rem;
    color: #e0e0e0;
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

.modal-btn {
    padding: 0.8rem 2rem;
    background: linear-gradient(135deg, #c4a747 0%, #8b7530 100%);
    border: none;
    border-radius: 8px;
    color: #1a1815;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.modal-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(196, 167, 71, 0.3);
}

/* Large Edit Modal */
.modal-content-large {
    max-width: 800px;
    width: 95%;
    max-height: 90vh;
    text-align: left;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(196, 167, 71, 0.2);
}

.modal-header .modal-title {
    margin-bottom: 0;
    font-size: 1.2rem;
}

.modal-close-btn {
    background: none;
    border: none;
    color: #888;
    font-size: 1.8rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}

.modal-close-btn:hover {
    color: #c4a747;
}

.modal-textarea {
    width: 100%;
    min-height: 400px;
    padding: 1rem;
    background: #1a1815;
    border: 1px solid rgba(196, 167, 71, 0.3);
    border-radius: 8px;
    color: #e0e0e0;
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.6;
    resize: vertical;
    flex: 1;
}

.modal-textarea:focus {
    outline: none;
    border-color: #c4a747;
    box-shadow: 0 0 0 2px rgba(196, 167, 71, 0.2);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(196, 167, 71, 0.2);
}

.modal-btn-secondary {
    background: transparent;
    border: 1px solid rgba(196, 167, 71, 0.5);
    color: #c4a747;
}

.modal-btn-secondary:hover {
    background: rgba(196, 167, 71, 0.1);
    transform: none;
    box-shadow: none;
}

.modal-btn-primary {
    background: linear-gradient(135deg, #c4a747 0%, #8b7530 100%);
    color: #1a1815;
}

/* Edit button in source cards */
.btn-edit-context {
    padding: 0.4rem 0.8rem;
    background: transparent;
    border: 1px solid rgba(196, 167, 71, 0.4);
    border-radius: 6px;
    color: #c4a747;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-edit-context:hover {
    background: rgba(196, 167, 71, 0.15);
    border-color: #c4a747;
}

/* ========================================
   Unified Input Area (simplified UI)
   ======================================== */
.unified-input-area {
    position: relative;
}

.unified-input-area textarea {
    padding-right: 55px;
    font-size: 1.05rem;
    line-height: 1.5;
}

.voice-btn-inline {
    position: absolute;
    right: 8px;
    top: 8px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid rgba(196, 167, 71, 0.4);
    background: rgba(196, 167, 71, 0.15);
    color: #c4a747;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.voice-btn-inline:hover {
    background: rgba(196, 167, 71, 0.25);
    border-color: #c4a747;
    transform: scale(1.05);
}

.voice-btn-inline.recording {
    background: rgba(220, 53, 69, 0.3);
    border-color: #dc3545;
    animation: pulse 1s infinite;
}

.voice-status {
    position: absolute;
    right: 60px;
    top: 16px;
    font-size: 0.85rem;
    color: #dc3545;
    font-style: italic;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ========================================
   Facts Sources Table with Checkboxes
   ======================================== */
.facts-sources-table {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.facts-sources-header {
    margin-bottom: 0.5rem;
}

.facts-sources-header .checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: #c4a747;
    cursor: pointer;
}

.facts-sources-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.source-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.source-row:hover {
    background: rgba(255, 255, 255, 0.08);
}

.source-checkbox {
    width: 18px;
    height: 18px;
    accent-color: #c4a747;
    cursor: pointer;
}

.source-title {
    flex: 1;
    font-size: 0.9rem;
    color: #e0e0e0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.source-link {
    color: #88c0d0;
    font-size: 0.9rem;
    text-decoration: none;
    padding: 0.25rem;
    border-radius: 4px;
    transition: all 0.2s;
}

.source-link:hover {
    color: #c4a747;
    background: rgba(196, 167, 71, 0.1);
}

/* Checkbox label styling */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #c4a747;
}

/* Modal title with em */
.modal-title em {
    font-style: normal;
    color: #88c0d0;
}

/* ========================================
   Search Results - Source Cards (inline)
   ======================================== */
.search-results {
    margin-top: 1rem;
    border: 1px solid rgba(196, 167, 71, 0.3);
    border-radius: 12px;
    background: rgba(196, 167, 71, 0.05);
    padding: 1rem;
}

.search-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(196, 167, 71, 0.2);
}

.search-results-header label {
    color: #c4a747;
    font-weight: 600;
    font-size: 1rem;
    margin: 0;
}

.btn-clear-search {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #888;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-clear-search:hover {
    background: rgba(220, 53, 69, 0.2);
    border-color: #dc3545;
    color: #dc3545;
}

.sources-table {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Individual source card */
.source-card {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 1rem;
    transition: border-color 0.2s;
}

.source-card:hover {
    border-color: rgba(196, 167, 71, 0.4);
}

.source-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.source-use-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: #c4a747;
    cursor: pointer;
    white-space: nowrap;
}

.source-use-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #c4a747;
    cursor: pointer;
}

.source-url-link {
    flex: 1;
    color: #88c0d0;
    text-decoration: none;
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: color 0.2s;
}

.source-url-link:hover {
    color: #c4a747;
    text-decoration: underline;
}

.source-context {
    width: 100%;
    min-height: 80px;
    padding: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.03);
    color: #e8e8e8;
    font-size: 0.9rem;
    line-height: 1.5;
    resize: vertical;
    transition: border-color 0.2s;
}

.source-context:focus {
    outline: none;
    border-color: #c4a747;
}

.source-context::placeholder {
    color: #666;
}

.source-card-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.75rem;
}

.btn-fetch-content {
    padding: 0.5rem 1rem;
    background: rgba(136, 192, 208, 0.15);
    border: 1px solid rgba(136, 192, 208, 0.4);
    border-radius: 6px;
    color: #88c0d0;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-fetch-content:hover:not(:disabled) {
    background: rgba(136, 192, 208, 0.25);
    border-color: #88c0d0;
}

.btn-fetch-content:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.fetch-status {
    font-size: 0.8rem;
    color: #888;
}

.fetch-status.success {
    color: #4caf50;
}

.fetch-status.error {
    color: #e57373;
}

/* Fetched content container */
.fetched-content-container {
    margin-top: 0.75rem;
    border-top: 1px solid rgba(136, 192, 208, 0.2);
    padding-top: 0.75rem;
}

.fetched-content-header {
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
}

.fetched-label {
    font-size: 0.85rem;
    color: #88c0d0;
}

.fetched-content-textarea {
    width: 100%;
    padding: 0.75rem;
    background: rgba(30, 35, 45, 0.6);
    border: 1px solid rgba(136, 192, 208, 0.25);
    border-radius: 6px;
    color: #d8dee9;
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.4;
    resize: vertical;
    min-height: 100px;
}

.fetched-content-textarea:focus {
    outline: none;
    border-color: rgba(136, 192, 208, 0.5);
}

/* Search loading spinner */
.search-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 2rem;
    color: #888;
    font-size: 1rem;
}

.search-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(196, 167, 71, 0.2);
    border-top-color: #c4a747;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Settings Button */
.settings-btn {
    background: none;
    border: none;
    color: #c4a747;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: background 0.2s;
}

.settings-btn:hover {
    background: rgba(196, 167, 71, 0.2);
}

/* Settings Modal */
.settings-modal {
    max-width: 500px;
}

.settings-section {
    margin-bottom: 1.5rem;
}

.settings-section h3 {
    margin-bottom: 1rem;
    color: #c4a747;
    font-size: 1rem;
}

.model-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.model-option {
    display: flex;
    align-items: center;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.model-option:hover {
    background: rgba(255, 255, 255, 0.1);
}

.model-option.selected {
    border-color: #c4a747;
    background: rgba(196, 167, 71, 0.1);
}

.model-option input[type="radio"] {
    display: none;
}

.model-option-info {
    flex: 1;
}

.model-option-name {
    font-weight: 600;
    color: #fff;
    margin-bottom: 0.25rem;
}

.model-option-desc {
    font-size: 0.85rem;
    color: #888;
}

.model-option-check {
    width: 24px;
    height: 24px;
    border: 2px solid #555;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.model-option.selected .model-option-check {
    border-color: #c4a747;
    background: #c4a747;
}

.model-option.selected .model-option-check::after {
    content: '✓';
    color: #1a1a2e;
    font-weight: bold;
}

.settings-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.5rem;
}
