/* リセット & ベーススタイル */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    line-height: 1.6;
}

.container {
    max-width: 900px;
    margin: 0 auto;
}

/* 認証・読み込み画面 */
.full-screen-center {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 80vh;
    width: 100%;
    color: white;
    text-align: center;
}

.login-card {
    max-width: 400px;
    width: 90%;
    text-align: center;
    color: #333;
}

.login-card h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: #667eea;
}

.login-card h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.login-card p {
    margin-bottom: 2rem;
    color: #666;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

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

.btn-sm {
    padding: 8px 16px;
    font-size: 0.8rem;
}

/* ヘッダー */
header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* カード */
.card {
    background: white;
    border-radius: 12px;
    padding: 30px;
    margin-bottom: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.card h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.8rem;
}

.card h3 {
    color: #555;
    margin-bottom: 15px;
    font-size: 1.3rem;
}

/* フォーム */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.info-tooltip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin-left: 6px;
    border-radius: 50%;
    border: 1px solid #a0aec0;
    color: #4a5568;
    font-size: 0.75rem;
    font-weight: 700;
    background: #edf2f7;
    cursor: help;
    position: relative;
    vertical-align: middle;
}

.info-tooltip::after {
    content: attr(data-tip);
    position: absolute;
    left: 0;
    bottom: 125%;
    min-width: 220px;
    max-width: 320px;
    padding: 8px 10px;
    border-radius: 8px;
    background: #2d3748;
    color: #f7fafc;
    font-weight: 400;
    font-size: 0.8rem;
    line-height: 1.4;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.15s ease;
    z-index: 20;
    text-align: left;
}

.info-tooltip:hover::after,
.info-tooltip:focus-visible::after {
    opacity: 1;
    visibility: visible;
}

.inline-info-note {
    margin-top: 6px;
    font-size: 0.85rem;
    color: #4a5568;
}

.data-handling-caution {
    margin-bottom: 8px;
    font-size: 0.86rem;
    line-height: 1.45;
    color: #744210;
    background: #fffaf0;
    border: 1px solid #fbd38d;
    border-radius: 8px;
    padding: 8px 10px;
}

.disclaimer-box {
    margin-top: 10px;
    font-size: 0.82rem;
    line-height: 1.5;
    color: #4a5568;
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px 12px;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

.form-group textarea {
    resize: vertical;
}

.readonly-input {
    background-color: #edf2f7;
    color: #4a5568;
    cursor: not-allowed;
}

.template-download-row {
    margin-top: 10px;
}

.template-download-row .btn {
    margin: 0;
    width: 100%;
    text-align: center;
    text-decoration: none;
}

.instruction-copy-group {
    margin-top: 8px;
    margin-bottom: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.instruction-copy-item,
.instruction-copy-summary {
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px dashed #a0aec0;
    background: #f7fafc;
    color: #2d3748;
    cursor: pointer;
    font-size: 0.85rem;
    line-height: 1.4;
}

.instruction-copy-item {
    text-align: left;
}

.instruction-copy-summary {
    border-style: solid;
    background: #edf2f7;
    font-weight: 600;
}

.instruction-copy-item:hover,
.instruction-copy-summary:hover {
    background: #e2e8f0;
}

.service-account-box {
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 10px;
}

.service-account-row {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    margin: 6px 0;
}

/* ボタン */
.btn {
    padding: 14px 28px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-block;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
    margin: 5px;
}

.btn-secondary:hover {
    background: #667eea;
    color: white;
}

.consultant-cta {
    margin-top: 12px;
}

.consultant-btn {
    width: 100%;
    margin: 0;
}

.consultant-form-link {
    display: inline-block;
    margin-top: 8px;
    color: #4a5568;
    font-size: 0.9rem;
    text-decoration: underline;
}

.consultant-form-link:hover {
    color: #2d3748;
}

.free-limit-box {
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    color: #4a5568;
    font-size: 0.9rem;
}

.free-limit-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    height: 22px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 700;
    color: #744210;
    background: #fefcbf;
    border: 1px solid #faf089;
}

.free-limit-box.is-locked {
    border-color: #fed7d7;
    background: #fff5f5;
    color: #c53030;
}

.upgrade-prompt {
    margin-top: 10px;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #fed7d7;
    background: #fff5f5;
}

.upgrade-prompt p {
    margin-bottom: 8px;
    color: #742a2a;
    font-size: 0.9rem;
}

.upgrade-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.upgrade-actions .btn {
    margin: 0;
    width: auto;
}

/* プログレス表示 */
.progress-info {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
}

.time-display {
    font-size: 1.3rem;
    margin-bottom: 20px;
    color: #333;
}

#elapsed-time {
    color: #667eea;
    font-weight: bold;
    font-size: 1.5rem;
}

.status-display {
    margin-bottom: 20px;
}

.status-stages {
    margin-top: 15px;
}

.status-stage {
    padding: 12px 16px;
    margin-bottom: 10px;
    border-radius: 8px;
    background: white;
    border: 2px solid #e0e0e0;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s;
}

.status-stage.active {
    background: #fff3cd;
    border-color: #ffc107;
    animation: pulse 1.5s infinite;
}

.status-stage.completed {
    background: #d4edda;
    border-color: #28a745;
}

.status-stage .status-icon {
    font-size: 1.3rem;
}

.status-stage.active .status-icon {
    animation: spin 2s linear infinite;
}

.status-stage.completed .status-icon::before {
    content: "✅";
}

.status-text {
    font-weight: 500;
    color: #333;
}

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

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

.run-id-display {
    margin-top: 20px;
    padding: 12px;
    background: white;
    border-radius: 8px;
}

.run-id-display code {
    background: #f1f3f5;
    padding: 4px 8px;
    border-radius: 4px;
    font-family: "Courier New", monospace;
    color: #667eea;
}

/* ダウンロードオプション */
.download-options {
    margin-bottom: 30px;
}

.result-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.result-header-row h2 {
    margin: 0;
}

.download-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* 分析内容 */
.analysis-content {
    margin-top: 30px;
}

.analysis-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.analysis-header-row h3 {
    margin: 0;
}

.content-box {
    background: #f8f9fa;
    background-color: #f5f5f5;
    border-radius: 8px;
    padding: 20px;
    max-height: 600px;
    overflow-y: auto;
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.6;
}

.content-box h1, .report-content h1,
.content-box h2, .report-content h2,
.content-box h3, .report-content h3 {
    margin-top: 8px;
    margin-bottom: 2px;
    color: #333;
}

.content-box h1, .report-content h1 {
    font-size: 1.8rem;
}

.content-box h2, .report-content h2 {
    font-size: 1.5rem;
}

.content-box h3, .report-content h3 {
    font-size: 1.3rem;
}

.content-box p, .report-content p {
    text-indent: 1em;
    margin-top: 0;
    margin-bottom: 1em;
}

.content-box ul, .report-content ul,
.content-box ol, .report-content ol {
    margin-top: 0;
    margin-left: 2em;
    margin-bottom: 1em;
}

.content-box li, .report-content li {
    margin-bottom: 0.5em;
}

.content-box code, .report-content code {
    background: #e9ecef;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: "Courier New", monospace;
}

.content-box pre, .report-content pre {
    background: #2d2d2d;
    color: #f8f8f2;
    padding: 15px;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 8px;
}

.content-box pre code, .report-content pre code {
    background: transparent;
    color: inherit;
}

.content-box table, .report-content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1em;
}

.content-box th, .report-content th,
.content-box td, .report-content td {
    border: 1px solid #000;
    padding: 8px;
    text-align: left;
}

.content-box th, .report-content th {
    background-color: #e2e8f0;
    font-weight: bold;
}

/* フッター */
footer {
    text-align: center;
    color: white;
    margin-top: 30px;
    opacity: 0.8;
}

/* 拡張スタイル: マルチフォーマット入力 */

.input-type-selector {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.radio-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 15px 10px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    font-size: 0.9rem;
    background: #fcfcfc;
}

.radio-option:hover {
    border-color: #667eea;
    background: #f0f4ff;
}

.radio-option input[type="radio"] {
    margin-bottom: 10px;
}

.radio-option:has(input[type="radio"]:checked) {
    border-color: #667eea;
    background: #f0f4ff;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

/* File Upload Widget */
.file-upload-widget {
    margin-top: 5px;
}

.drop-zone {
    border: 3px dashed #cbd5e1;
    border-radius: 12px;
    padding: 30px;
    text-align: center;
    background: #f8fafc;
    transition: all 0.3s ease;
    cursor: pointer;
}

.drop-zone:hover, .drop-zone.drag-over {
    border-color: #667eea;
    background: #f0f4ff;
}

.drop-zone p {
    color: #64748b;
    margin-bottom: 15px;
    font-weight: 500;
}

#file-info {
    margin-top: 15px;
    padding: 12px 18px;
    background: #e6fffa;
    border: 1px solid #38b2ac;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.file-name {
    font-weight: bold;
    color: #234e52;
}

.file-size {
    color: #2c7a7b;
    font-size: 0.85rem;
    margin-left: 10px;
}

.remove-file {
    background: none;
    border: none;
    color: #e53e3e;
    font-size: 1.4rem;
    cursor: pointer;
    line-height: 1;
}

.remove-file:hover {
    color: #c53030;
}

.encoding-selector select {
    padding: 8px 12px;
    border-radius: 6px;
    border: 2px solid #e2e8f0;
    margin-left: 10px;
    background: white;
}

/* Info Boxes */
.info-box {
    margin-top: 15px;
    padding: 15px;
    border-radius: 8px;
    font-size: 0.9rem;
    line-height: 1.5;
}

.info-box.warning {
    background: #fffaf0;
    border-left: 4px solid #ed8936;
    color: #7b341e;
}

.info-box ul {
    margin-top: 8px;
    margin-left: 20px;
}

/* Data Preview */
#data-preview-container {
    background: #f7fafc;
    border: 2px solid #edf2f7;
}

#data-preview {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    background: #1a202c;
    color: #f7fafc;
    padding: 15px;
    border-radius: 8px;
    margin-top: 10px;
}

@media (max-width: 768px) {
    .input-type-selector {
        grid-template-columns: 1fr 1fr;
    }
}

/* レスポンシブデザイン */
@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }

    .card {
        padding: 20px;
    }

    .download-buttons {
        flex-direction: column;
    }

    .btn-secondary {
        width: 100%;
        margin: 5px 0;
    }
}

/* === CopilotKit 要件定義AIモーダル === */

/* モーダルオーバーレイ */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
    animation: fadeIn 0.2s ease-out;
}

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

/* モーダルコンテンツ */
.modal-content {
    background-color: white;
    border-radius: 16px;
    width: 90%;
    max-width: 650px;
    height: 98vh;
    max-height: 98vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* モーダルヘッダー */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid #e2e8f0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 16px 16px 0 0;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 600;
}

.close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    font-size: 1.8rem;
    cursor: pointer;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    line-height: 1;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* モーダルボディ */
.modal-body {
    padding: 20px 25px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    flex: 1;
    overflow-y: auto; /* コンテンツが溢れた場合はスクロールさせる */
    min-height: 0; /* Flexboxの縮小を有効にするため */
}

/* チャット履歴エリア */
.chat-history {
    flex: 1;
    overflow-y: auto;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 15px;
    background-color: #f7fafc;
    min-height: 150px; /* 入力欄が大きいので最小高さを抑制 */
}

.chat-history::-webkit-scrollbar {
    width: 8px;
}

.chat-history::-webkit-scrollbar-track {
    background: #edf2f7;
    border-radius: 10px;
}

.chat-history::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 10px;
}

.chat-history::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* チャットメッセージ */
.chat-message {
    margin-bottom: 14px;
    padding: 12px 16px;
    border-radius: 12px;
    max-width: 85%;
    word-wrap: break-word;
    white-space: pre-wrap; /* 改行を保持 */
    animation: messageSlide 0.2s ease-out;
    line-height: 1.5;
    font-size: 0.9rem; /* 文字サイズを少し小さく */
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.user {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    margin-left: auto;
    text-align: right;
    border-bottom-right-radius: 4px;
}

.chat-message.assistant {
    background-color: #edf2f7;
    color: #2d3748;
    margin-right: auto;
    border-bottom-left-radius: 4px;
    border: 1px solid #e2e8f0;
}

.chat-message.system {
    background-color: #fef5e7;
    color: #975a16;
    margin: 0 auto;
    text-align: center;
    font-size: 0.9rem;
    border: 1px solid #f9e79f;
}

.chat-history .placeholder {
    text-align: center;
    color: #a0aec0;
    font-style: italic;
    padding: 80px 20px;
    font-size: 1.05rem;
}

/* 入力エリア */
.chat-input-area {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-top: 5px;
}

.chat-input-area textarea {
    resize: none;
    padding: 12px 14px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color 0.2s ease;
}

.chat-input-area textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.input-actions {
    display: flex;
    gap: 10px;
    width: 100%;
}

.action-btn {
    padding: 10px 16px;
    font-size: 0.95rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
    justify-content: center;
    align-items: center;
    display: flex;
}

#send-message-btn {
    flex: 4;
}

#start-analysis-chat-btn {
    flex: 4;
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
}

#reset-requirements-btn {
    flex: 1;
    background: #e53e3e;
    min-width: 50px;
}

.chat-input-area button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* 成功バナー */
.success-banner {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
    padding: 14px 20px;
    border-radius: 8px;
    text-align: center;
    font-weight: 600;
    margin-top: 10px;
    animation: slideIn 0.3s ease-out;
    box-shadow: 0 4px 12px rgba(72, 187, 120, 0.3);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* クリアボタン */
.clear-history-btn {
    background-color: #f56565;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.clear-history-btn:hover {
    background-color: #e53e3e;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        height: 100vh;
        max-height: 100vh;
    }
    
    .modal-header {
        padding: 15px 20px;
    }
    
    .modal-header h3 {
        font-size: 1.1rem;
    }
    
    .modal-body {
        padding: 15px 20px;
    }
    
    .chat-history {
        min-height: 250px;
        max-height: 350px;
    }
    
    .chat-message {
        max-width: 90%;
        font-size: 0.95rem;
    }
}

/* �v����`�t�H�[�� */
.requirements-form-container {
    margin-top: 15px;
    background: #fff;
    padding: 0;
    border-radius: 8px;
    border: 1px solid #ccc;
    overflow: visible;
}

.requirements-table {
    width: 100%;
    border-collapse: collapse;
}

.requirements-table th, .requirements-table td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

.requirements-table th {
    background-color: #fff;
    font-weight: normal;
    font-size: 0.9rem;
    color: #333;
    text-align: center;
    width: 30%;
    border-right: 1px solid #ddd;
}

.requirements-table td {
    padding: 0;
}

.requirements-table td input {
    width: 100%;
    padding: 10px;
    border: none;
    font-size: 0.95rem;
    outline: none;
}

.requirements-table tr:last-child th,
.requirements-table tr:last-child td {
    border-bottom: none;
}

/* === Modern Design Tokens (kss-tt-frontend style) === */
:root {
    --background: #f5f5f5;
    --foreground: #171717;
    --card: #fafafa;
    --card-foreground: #171717;
    --popover: #e3e3e3;
    --popover-foreground: #171717;
    --primary: #e96a17;
    --primary-foreground: #fff7ed;
    --secondary: #525252;
    --secondary-foreground: #fafafa;
    --muted: #a1a1a1;
    --muted-foreground: #262626;
    --accent: #fffaeb;
    --accent-foreground: #f59e0b;
    --destructive: #dc2626;
    --destructive-foreground: #fef2f2;
    --border: #d4d4d4;
    --input: #d4d4d4;
    --ring: #e96a17;
    --radius: 12px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 12px 30px rgba(0, 0, 0, 0.12);
}

body[data-theme="sunset"] {
    --background: #f4e6db;
    --foreground: #2f170b;
    --card: #f7eee7;
    --card-foreground: #2f170b;
    --primary: #9a3412;
    --primary-foreground: #fff7ed;
    --secondary: #6b2a12;
    --border: #d4a98d;
    --input: #ca9a82;
    --ring: #9a3412;
}

body[data-theme="forest"] {
    --background: #ddece0;
    --foreground: #0b2314;
    --card: #e8f2ea;
    --card-foreground: #0b2314;
    --primary: #166534;
    --primary-foreground: #f0fdf4;
    --secondary: #14532d;
    --border: #95c0a4;
    --input: #83b295;
    --ring: #166534;
}

body[data-theme="ocean"] {
    --background: #dceaf5;
    --foreground: #0d2235;
    --card: #e8f1f8;
    --card-foreground: #0d2235;
    --primary: #075985;
    --primary-foreground: #f0f9ff;
    --secondary: #0c4a6e;
    --border: #8fb2cb;
    --input: #7ea5c2;
    --ring: #075985;
}

body[data-theme="mono"] {
    --background: #dddddd;
    --foreground: #111111;
    --card: #e7e7e7;
    --card-foreground: #111111;
    --primary: #2e2e2e;
    --primary-foreground: #fafafa;
    --secondary: #3f3f46;
    --border: #9a9a9a;
    --input: #909090;
    --ring: #2e2e2e;
}

body[data-theme="dark-slate"] {
    --background: #0f172a;
    --foreground: #e2e8f0;
    --card: #111827;
    --card-foreground: #e5e7eb;
    --primary: #38bdf8;
    --primary-foreground: #082f49;
    --secondary: #94a3b8;
    --secondary-foreground: #0f172a;
    --muted: #475569;
    --muted-foreground: #cbd5e1;
    --accent: #1e293b;
    --accent-foreground: #bae6fd;
    --border: #334155;
    --input: #334155;
    --ring: #38bdf8;
}

body[data-theme="dark-indigo"] {
    --background: #0b1020;
    --foreground: #e0e7ff;
    --card: #11152a;
    --card-foreground: #e5e7ff;
    --primary: #818cf8;
    --primary-foreground: #1e1b4b;
    --secondary: #a5b4fc;
    --secondary-foreground: #11152a;
    --muted: #4c5178;
    --muted-foreground: #c7d2fe;
    --accent: #1f2540;
    --accent-foreground: #c7d2fe;
    --border: #31385f;
    --input: #31385f;
    --ring: #818cf8;
}

body[data-theme="dark-emerald"] {
    --background: #061810;
    --foreground: #d1fae5;
    --card: #0a2218;
    --card-foreground: #dcfce7;
    --primary: #34d399;
    --primary-foreground: #022c22;
    --secondary: #6ee7b7;
    --secondary-foreground: #0a2218;
    --muted: #2f5f4f;
    --muted-foreground: #a7f3d0;
    --accent: #113128;
    --accent-foreground: #a7f3d0;
    --border: #245544;
    --input: #245544;
    --ring: #34d399;
}

body[data-theme="dark-amber"] {
    --background: #1a1205;
    --foreground: #fef3c7;
    --card: #23170a;
    --card-foreground: #fffbeb;
    --primary: #f59e0b;
    --primary-foreground: #451a03;
    --secondary: #fbbf24;
    --secondary-foreground: #23170a;
    --muted: #7a5a20;
    --muted-foreground: #fde68a;
    --accent: #31220f;
    --accent-foreground: #fde68a;
    --border: #5b4320;
    --input: #5b4320;
    --ring: #f59e0b;
}

body[data-theme="dark-rose"] {
    --background: #1a0a12;
    --foreground: #ffe4ef;
    --card: #25101a;
    --card-foreground: #ffe6f1;
    --primary: #fb7185;
    --primary-foreground: #4c0519;
    --secondary: #fda4af;
    --secondary-foreground: #25101a;
    --muted: #7a3e56;
    --muted-foreground: #fecdd3;
    --accent: #341725;
    --accent-foreground: #fecdd3;
    --border: #633046;
    --input: #633046;
    --ring: #fb7185;
}

/* === Global tone overrides (non-breaking) === */
body {
    font-family: "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    background: var(--background);
    color: var(--foreground);
}

/* ----- Contrast & button improvements ----- */
/* stronger interactive states for buttons and improved visibility */
.btn {
    transition: transform 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}
.btn:hover {
    transform: translateY(-3px) scale(1.02);
}
.btn-primary {
    box-shadow: 0 8px 20px rgba(0,0,0,0.08);
    background: #d35400; /* slightly stronger primary */
    color: #fff;
}
.btn-primary:hover {
    box-shadow: 0 18px 40px rgba(0,0,0,0.14);
}
.btn-secondary {
    background: #ffffff;
    color: #1f2937;
    border: 1px solid #cfcfcf;
}
.btn-secondary:hover {
    background: #1f2937;
    color: #ffffff;
    border-color: #1f2937;
}
.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px rgba(211,83,0,0.12);
}

/* Plan card emphasis */
.plan-card {
    border: 1px solid rgba(0,0,0,0.06);
    background: #ffffff;
}
.plan-card.popular {
    border-color: rgba(211,83,0,0.18);
    box-shadow: 0 18px 40px rgba(211,83,0,0.06);
}
.plan-price { color: #d35400; font-weight: 900; }

/* Improve contrast for card and text */
.card { background: #ffffff; color: #0f1720; border-color: #d0d0d0; }
.subtitle { color: #374151; }
.info-tooltip::after { background: #111827; color: #ffffff; }

@media (prefers-contrast: more) {
    .btn-primary { box-shadow: 0 20px 50px rgba(0,0,0,0.18); }
    .plan-card { border-color: #bdbdbd; }
}

/* Pricing page styles */
.plans-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-top: 18px;
}
.plan-card {
    padding: 22px;
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    text-align: center;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.plan-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 18px 50px rgba(16,24,40,0.12);
}
.plan-card.popular {
    background: linear-gradient(180deg, #fff 0%, #fffefb 100%);
    border: 1px solid rgba(233,106,23,0.12);
}
.plan-card.enterprise {
    background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
}
.plan-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-direction: column;
    margin-bottom: 12px;
}
.plan-header h3 {
    font-size: 1.15rem;
    margin: 0;
}
.badge { 
    background: var(--primary);
    color: var(--primary-foreground);
    padding: 6px 10px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.75rem;
}
.plan-price {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--foreground);
}
.plan-price .period { 
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--muted);
    margin-left: 6px;
}
.plan-features {
    list-style: none;
    padding: 0;
    margin: 12px 0 18px 0;
    color: var(--muted-foreground);
    font-size: 0.95rem;
}
.plan-features li {
    padding: 8px 0;
    border-top: 1px dashed rgba(0,0,0,0.04);
}
.plan-actions { 
    margin-top: 8px;
}
.plans-footer { 
    margin-top: 18px;
    text-align: center;
}

@media (max-width: 1100px) {
    .plans-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
    .plans-grid { grid-template-columns: 1fr; }
}

/* Billing toggle styles */
.billing-toggle { margin-top: 8px; }
.billing-toggle .btn { padding: 8px 12px; border-radius: 8px; }
.billing-toggle .btn-primary { padding-left: 12px; padding-right: 12px; }

.container {
    max-width: 1040px;
}

header {
    color: var(--foreground);
    margin-bottom: 20px;
}

header h1 {
    font-size: 2rem;
    text-shadow: none;
    letter-spacing: -0.01em;
}

.subtitle {
    color: #525252;
    opacity: 1;
}

.full-screen-center {
    color: var(--foreground);
    min-height: 100vh;
}

.login-card {
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
}

.login-card h1 {
    color: var(--primary);
}

.spinner {
    border: 5px solid rgba(0, 0, 0, 0.1);
    border-top-color: var(--primary);
}

.card,
#data-preview-container,
.run-id-display,
.progress-info,
.service-account-box,
.info-box,
.free-limit-box,
.disclaimer-box,
.content-box,
.chat-history,
.modal-content {
    background: var(--card);
    color: var(--card-foreground);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.card {
    padding: 24px;
    box-shadow: var(--shadow-md);
}

.card h2,
.card h3,
.status-text,
.time-display {
    color: var(--foreground);
}

.form-group label {
    color: var(--foreground);
}

.form-group input,
.form-group textarea,
.form-group select,
.chat-input-area textarea,
.encoding-selector select {
    border: 1px solid var(--input);
    border-radius: 10px;
    background: #ffffff;
    color: var(--foreground);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus,
.chat-input-area textarea:focus,
.encoding-selector select:focus {
    border-color: var(--ring);
    box-shadow: 0 0 0 3px rgba(233, 106, 23, 0.15);
}

.readonly-input {
    background: #f5f5f5;
    color: #737373;
}

.btn,
.action-btn,
.clear-history-btn {
    border-radius: 10px;
    border: 1px solid transparent;
    font-weight: 600;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: var(--primary-foreground);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 16px rgba(233, 106, 23, 0.25);
}

.btn-secondary {
    background: #ffffff;
    color: var(--secondary);
    /* border: 1px solid var(--border); */
}

.btn-secondary:hover {
    background: #fafafa;
    /* color: var(--foreground); */
    color: blue;
    /* border-color: #a3a3a3; */
}

.tab-container {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 6px;
}

.tab-btn {
    border: 1px solid transparent;
    background: transparent;
    color: #525252;
    border-radius: 8px;
    margin: 0;
}

.tab-btn.active {
    background: var(--primary);
    color: var(--primary-foreground);
    box-shadow: var(--shadow-sm);
}

.data-handling-caution {
    color: #7c2d12;
    background: #fff7ed;
    border: 1px solid #fdba74;
}

.info-tooltip {
    border: 1px solid var(--border);
    color: #525252;
    background: #fafafa;
}

.info-tooltip::after {
    background: #262626;
    color: #fafafa;
}

.status-stage {
    background: #ffffff;
    border: 1px solid var(--border);
}

.status-stage.active {
    background: #fff7ed;
    border-color: #fdba74;
}

.status-stage.completed {
    background: #f0fdf4;
    border-color: #86efac;
}

#elapsed-time,
.run-id-display code {
    color: var(--primary);
}

.drop-zone {
    border: 2px dashed #d4d4d4;
    background: #fafafa;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--primary);
    background: #fff7ed;
}

.radio-option {
    border: 1px solid var(--border);
    background: #ffffff;
}

.radio-option:hover,
.radio-option:has(input[type="radio"]:checked) {
    border-color: var(--primary);
    background: #fff7ed;
    box-shadow: none;
}

.modal {
    background-color: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(3px);
}

.modal-header {
    background: #171717;
    border-bottom: 1px solid #262626;
}

.chat-message.user {
    background: var(--primary);
}

.chat-message.assistant {
    background: #f5f5f5;
    color: #262626;
    border: 1px solid #e5e5e5;
}

.success-banner {
    background: #16a34a;
}

.requirements-form-container,
.requirements-table th,
.requirements-table th,
.requirements-table td {
    border-color: #d4d4d4;
}

footer {
    color: #525252;
}

@media (max-width: 768px) {
    body {
        padding: 14px;
    }

    .card {
        padding: 18px;
        border-radius: 10px;
    }

    header h1 {
        font-size: 1.6rem;
    }
}

/* === Layout helpers for index.html (non-breaking) === */
.app-header-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    position: relative;
}

.app-header-row h1 {
    width: 100%;
    text-align: center;
}

.user-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    position: fixed;
    top: 14px;
    right: 18px;
    z-index: 1100;
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.72);
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(6px);
}

.user-menu-toggle {
    min-width: 36px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.user-menu-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 280px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--card);
    color: var(--card-foreground);
    box-shadow: var(--shadow-md);
}

.user-menu-row {
    display: grid;
    grid-template-columns: 72px 1fr;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.user-menu-label {
    font-size: 0.78rem;
    color: #737373;
}

.user-id-display,
.user-display-name {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--foreground);
    overflow-wrap: anywhere;
}

.user-menu-theme-row {
    align-items: flex-start;
    margin-top: 10px;
}

.theme-select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--input);
    border-radius: 8px;
    background: #fff;
    color: var(--foreground);
}

.theme-select:focus {
    outline: none;
    border-color: var(--ring);
    box-shadow: 0 0 0 3px rgba(233, 106, 23, 0.15);
}

.user-menu-logout {
    margin-top: 6px;
    width: 100%;
}

.user-nav .btn {
    padding: 6px 10px;
    font-size: 0.78rem;
}

.user-nav .user-display-name {
    font-size: 0.78rem;
}

.user-display-name {
    font-size: 0.9em;
    color: #525252;
}

.tab-container {
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
}

.workflow-header {
    margin-bottom: 16px;
    border: 1px solid var(--border);
    background: linear-gradient(180deg, #ffffff 0%, #fafafa 100%);
}

.workflow-header h2 {
    margin-bottom: 8px;
}

.workflow-lead {
    color: #525252;
    margin-bottom: 12px;
    font-size: 0.96rem;
}

.workflow-steps {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.workflow-step {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid #fdba74;
    background: #fff7ed;
    color: #7c2d12;
    font-size: 0.82rem;
    font-weight: 600;
}

.tab-btn {
    flex: 1;
}

.tab-helper-text {
    margin-top: -8px;
    margin-bottom: 16px;
    color: #737373;
    font-size: 0.86rem;
}

.section-caption {
    margin-top: -8px;
    margin-bottom: 16px;
    color: #737373;
    font-size: 0.9rem;
}

.panel-subtle {
    background-color: #f5f5f5;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
}

.panel-muted {
    background-color: #fafafa;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
}

.form-label-top {
    margin-top: 10px;
    display: block;
}

.auth-help {
    color: #737373;
    display: block;
    margin-top: 5px;
}

.auth-actions {
    margin-top: 10px;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.auth-status {
    color: #525252;
}

.encoding-selector {
    margin-top: 10px;
}

.service-account-row-gap {
    margin-bottom: 8px;
}

.form-inline-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.form-inline-row input {
    flex: 1;
}

.data-preview-card {
    margin-bottom: 20px;
}

.helper-cta-btn {
    width: 100%;
    margin-bottom: 10px;
}

.full-width-btn {
    width: 100%;
    margin-bottom: 15px;
}

.input-actions-spaced {
    margin-top: 15px;
}

.input-actions-spaced .action-btn {
    flex: 1;
}

.btn-success {
    background: #16a34a;
    color: #f0fdf4;
    border-color: #15803d;
}

.btn-success:hover {
    background: #15803d;
}

.btn-danger {
    background: #dc2626;
    color: #fef2f2;
    border-color: #b91c1c;
}

.btn-danger:hover {
    background: #b91c1c;
}

#reset-requirements-btn {
    flex: 0 0 140px;
}

#data-preview {
    white-space: pre-wrap;
    font-size: 0.85rem;
    max-height: 200px;
    overflow-y: auto;
}

@media (max-width: 768px) {
    .app-header-row {
        flex-direction: column;
        align-items: center;
    }

    .app-header-row h1 {
        text-align: center;
    }

    .user-nav {
        top: 10px;
        right: 10px;
        padding: 4px 6px;
        gap: 4px;
    }

    .user-menu-panel {
        min-width: 240px;
        max-width: calc(100vw - 24px);
    }

    .workflow-step {
        width: 100%;
        justify-content: center;
    }

    .form-inline-row {
        flex-direction: column;
    }

    .input-actions-spaced {
        flex-direction: column;
    }

    #reset-requirements-btn {
        flex: 1;
    }
}

