:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --bg-color: #0f172a;
    --text-color: #f8fafc;
    --card-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
}

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

body {
    font-family: 'Inter', 'Noto Sans JP', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    background-image:
        radial-gradient(circle at 20% 30%, rgba(118, 75, 162, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(102, 126, 234, 0.15) 0%, transparent 50%);
    overflow-x: hidden;
}

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 2rem 3rem 2rem;
    text-align: center;
}

header {
    margin-bottom: 2rem;
    animation: fadeInDown 1s ease-out;
    padding-top: 1rem;
}

.main-title {
    font-family: 'Outfit', sans-serif;
    font-size: 1.8rem;
    /* 小さくシンプルに */
    font-weight: 700;
    margin-bottom: 0.2rem;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

.subtitle {
    font-size: 1.2rem;
    color: #94a3b8;
    font-weight: 400;
}

.hero-section {
    display: flex;
    justify-content: center;
    perspective: 1000px;
}

.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 3rem;
    max-width: 500px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    animation: fadeInUp 1s ease-out 0.3s both;
}

.glass-card:hover {
    transform: translateY(-10px) rotateX(2deg);
    box-shadow: 0 35px 60px -15px rgba(0, 0, 0, 0.6);
    border-color: rgba(255, 255, 255, 0.2);
}

h2 {
    margin-bottom: 1.5rem;
    font-size: 1.8rem;
    color: #e2e8f0;
}

p {
    line-height: 1.6;
    margin-bottom: 2rem;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    background: rgba(34, 197, 94, 0.1);
    color: #4ade80;
    padding: 0.5rem 1.25rem;
    border-radius: 9999px;
    font-weight: 600;
    font-size: 0.9rem;
    border: 1px solid rgba(74, 222, 128, 0.2);
}

.status-icon {
    width: 8px;
    height: 8px;
    background-color: #4ade80;
    border-radius: 50%;
    margin-right: 0.75rem;
    box-shadow: 0 0 8px #4ade80;
    animation: pulse 2s infinite;
}

footer {
    margin-top: 4rem;
    color: #64748b;
    font-size: 0.9rem;
}

/* Controls Section */
.controls-section {
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    /* 両端寄せ */
    align-items: flex-end;
    gap: 1rem;
}

.glass-card.controls {
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 1.5rem 2.5rem;
}

.control-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
}

.control-group label {
    font-size: 0.8rem;
    color: #94a3b8;
    font-weight: 600;
}

.custom-select {
    background-color: #1e293b;
    /* 透過なしの背景色に変更 */
    border: 1px solid var(--glass-border);
    color: var(--text-color);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 1rem;
    min-width: 200px;
}

.custom-select option {
    background-color: #1e293b;
    color: #f8fafc;
}

.button-group {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
}

.btn {
    padding: 0.6rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    font-size: 0.9rem;
}

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

.btn-secondary {
    background: rgba(148, 163, 184, 0.1);
    color: #94a3b8;
    border: 1px solid rgba(148, 163, 184, 0.2);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-accent {
    background: linear-gradient(135deg, #0cebeb 0%, #20e3b2 50%, #29ffc6 100%);
    color: #0f172a;
}

.btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.2);
}

/* Management Tabs - Screen Transition Style */
.management-list-view.hidden {
    display: none !important;
}

.hidden {
    display: none !important;
}

.prompt-editor-card {
    max-width: 900px !important;
    margin: 0 auto;
    padding: 2.5rem;
    text-align: left;
}

.editor-header {
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 1rem;
}

.current-space-label {
    font-size: 1.1rem;
    color: #4ade80;
    font-weight: 700;
    margin-top: 0.3rem;
    margin-bottom: 0;
}

.prompts-grid {
    display: grid;
    grid-template-columns: 1fr;
    /* 1列に変更 */
    gap: 1.5rem;
}

.prompt-item label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    color: #94a3b8;
    font-weight: 600;
}

.prompt-item textarea {
    width: 100%;
    min-height: 120px;
    /* 1列7行で見やすくするため少し高さを調整 */
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: white;
    font-family: inherit;
    line-height: 1.5;
    resize: vertical;
}

.editor-footer {
    margin-top: 2.5rem;
    display: flex;
    justify-content: center;
    gap: 1.5rem;
}

/* Modal Styling */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.3s;
}

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

.modal-content {
    background: #1e293b;
    border: 1px solid var(--glass-border);
    padding: 2.5rem;
    border-radius: 20px;
    min-width: 400px;
    text-align: left;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
}

.modal-content h3 {
    margin-bottom: 1.5rem;
    font-family: 'Outfit', sans-serif;
}

.button-row {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    width: 100%;
}

.btn-sm {
    padding: 0.4rem 1rem;
    font-size: 0.8rem;
    flex: 1;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: #94a3b8;
}

.input-group input {
    width: 100%;
    padding: 0.8rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: white;
    margin-bottom: 1.5rem;
}

.modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

.btn-confirm {
    background: var(--primary-gradient);
    color: white;
}

.btn-cancel {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: #94a3b8;
}

/* Sticky Header & Nav */
.top-sticky-container {
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: #0f172a;
    /* 透過なしにしてスクロール時の重なりを防ぐ、またはblurをしっかりかける */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 1rem 0;
    border-bottom: 1px solid var(--glass-border);
    margin-bottom: 2rem;
}

header {
    margin-bottom: 1rem;
    animation: fadeInDown 0.8s ease-out;
}

.tabs-nav {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0;
}

.tab-link {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: #94a3b8;
    padding: 0.8rem 2rem;
    border-radius: 9999px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.tab-link.active {
    background: var(--primary-gradient);
    color: white;
    border-color: transparent;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

/* Tab Content */
.tab-pane {
    display: none;
    animation: fadeInUp 0.5s ease-out;
}

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

/* Question Tab / Prompt Section */
.action-card {
    margin-left: auto;
    /* 右寄せを保証 */
}

.action-group {
    min-width: 180px;
}

/* Question Tab Matrix */
.query-matrix-section {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.query-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.query-header {
    display: grid;
    grid-template-columns: 1fr 1fr 100px;
    gap: 1rem;
    padding: 0 1rem;
    font-size: 0.8rem;
    color: #94a3b8;
    font-weight: 600;
    align-items: center;
}

.header-action {
    display: flex;
    justify-content: center;
}

.run-all-label {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    cursor: pointer;
    white-space: nowrap;
}

.run-all-label input {
    width: auto;
    margin: 0;
}

.query-row {
    display: grid;
    grid-template-columns: 1fr 1fr 100px;
    gap: 1rem;
    align-items: flex-start;
    /* 上寄せに変更 */
    background: rgba(255, 255, 255, 0.02);
    padding: 0.8rem;
    /* 少し余白を調整 */
    border-radius: 8px;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.query-row:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--glass-border);
}

.query-editor,
.query-user-input,
.query-user-input-large {
    width: 100%;
    min-height: 80px;
    padding: 0.8rem;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    color: white;
    font-family: inherit;
    font-size: 0.9rem;
    resize: vertical;
}

.query-editor:focus,
.query-user-input:focus,
.query-user-input-large:focus {
    outline: none;
    border-color: #667eea;
}

.final-input-container {
    padding: 1.5rem;
    text-align: left;
    width: 100%;
    max-width: none;
    /* 制限を解除して横いっぱいに */
}

.final-input-container label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    color: #94a3b8;
}

.query-user-input-large {
    min-height: 120px;
}

/* Management Tabs */
.management-card {
    max-width: 800px;
    margin: 0 auto;
    padding: 2.5rem;
    text-align: left;
}

.management-card h3 {
    margin-bottom: 1.5rem;
    font-family: 'Outfit', sans-serif;
    font-size: 1.5rem;
}

.list-controls {
    display: flex;
    gap: 2rem;
}

.custom-list {
    flex: 1;
    background-color: #1e293b;
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    color: white !important;
    font-size: 1rem;
    outline: none;
    padding: 0;
    color-scheme: dark;
}

.custom-list option {
    background-color: #1e293b !important;
    color: white !important;
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.custom-list option:checked,
.custom-list option:focus,
.custom-list option:active {
    background-color: #4f46e5 !important;
    color: white !important;
}

.list-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 180px;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.5);
        opacity: 0.5;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@media (max-width: 768px) {
    .main-title {
        font-size: 2.5rem;
    }

    .glass-card {
        padding: 2rem;
    }
}

/* Print functionality */
#print-area {
    display: none;
}

@media print {
    body * {
        visibility: hidden;
    }

    #print-area,
    #print-area * {
        visibility: visible;
    }

    #print-area {
        display: block !important;
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        color: #000;
        background: #fff;
        padding: 20mm;
    }

    .print-page h1 {
        font-size: 24pt;
        border-bottom: none;
    }

    .print-page h2 {
        font-size: 16pt;
        margin-top: 2rem;
        border-bottom: 2px solid #000;
    }

    .print-page div {
        font-size: 11pt;
        line-height: 1.6;
    }
}