/* ===========================
   CSS Variables & Reset
   =========================== */
:root {
    --bg-primary: #0f0f14;
    --bg-secondary: #16171e;
    --bg-card: #1c1d27;
    --bg-input: #22232f;
    --bg-hover: #282938;
    --glass-bg: rgba(28, 29, 39, 0.85);
    --glass-border: rgba(255, 255, 255, 0.06);

    --text-primary: #e8e8ed;
    --text-secondary: #9b9cb0;
    --text-muted: #5e5f72;

    --accent-blue: #5b8af5;
    --accent-purple: #9b72f2;
    --accent-pink: #e46ba3;
    --accent-green: #4ecf8b;
    --accent-orange: #f0a456;

    --gradient-main: linear-gradient(135deg, #5b8af5, #9b72f2);
    --gradient-warm: linear-gradient(135deg, #e46ba3, #f0a456);
    --gradient-cool: linear-gradient(135deg, #4ecf8b, #5b8af5);

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 20px rgba(91, 138, 245, 0.15);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --font-main: 'Noto Sans JP', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-smooth: 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-main);
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
}

/* ===========================
   App Layout
   =========================== */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ===========================
   Sidebar
   =========================== */
.sidebar {
    width: 280px;
    min-width: 280px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 24px 20px;
    overflow-y: auto;
    transition: transform var(--transition-smooth);
}

.sidebar-header {
    margin-bottom: 32px;
}

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

.logo-icon {
    font-size: 1.4rem;
}

.logo h1 {
    font-size: 1.1rem;
    font-weight: 600;
    background: var(--gradient-main);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-sub {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 4px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* Steps */
.section-title {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 16px;
}

.steps {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-bottom: 32px;
}

.step {
    display: flex;
    gap: 14px;
    padding: 8px 0;
    opacity: 0.4;
    transition: opacity var(--transition-normal);
}

.step.active {
    opacity: 1;
}

.step.completed {
    opacity: 0.7;
}

.step-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.step-circle {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg-input);
    border: 2px solid var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    transition: all var(--transition-normal);
    flex-shrink: 0;
}

.step.active .step-circle {
    background: var(--gradient-main);
    border-color: transparent;
    color: white;
    box-shadow: var(--shadow-glow);
}

.step.completed .step-circle {
    background: var(--accent-green);
    border-color: transparent;
    color: white;
}

.step.completed .step-circle::after {
    content: '✓';
    font-size: 0.8rem;
}

.step.completed .step-circle {
    font-size: 0;
}

.step-line {
    width: 2px;
    flex: 1;
    min-height: 16px;
    background: var(--bg-input);
    margin-top: 4px;
    border-radius: 1px;
    transition: background var(--transition-normal);
}

.step.completed .step-line {
    background: var(--accent-green);
}

.step.active .step-line {
    background: var(--accent-blue);
}

.step-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-top: 4px;
}

.step-name {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-primary);
}

.step-agent {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.step.active .step-agent {
    color: var(--accent-blue);
}

/* Agent Cards */
.agent-cards {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.agent-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    transition: all var(--transition-normal);
}

.agent-card.active {
    border-color: rgba(91, 138, 245, 0.3);
    box-shadow: var(--shadow-glow);
}

.agent-avatar {
    font-size: 1.3rem;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--bg-input);
}

.agent-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.agent-name {
    font-size: 0.82rem;
    font-weight: 500;
}

.agent-role {
    font-size: 0.68rem;
    color: var(--text-muted);
}

.agent-status {
    margin-left: auto;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

.active-dot {
    background: var(--accent-green) !important;
    box-shadow: 0 0 8px rgba(78, 207, 139, 0.5);
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* ===========================
   Main Content
   =========================== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* ===========================
   Chat Panel
   =========================== */
.chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-secondary);
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px;
}

.chat-header-info h2 {
    font-size: 0.95rem;
    font-weight: 600;
}

.chat-status {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--bg-hover);
    border-radius: 2px;
}

/* Welcome Message */
.welcome-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 60px 20px;
    animation: fadeIn 0.6s ease;
}

.welcome-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}

.welcome-message h2 {
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 8px;
    background: var(--gradient-main);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-message p {
    color: var(--text-secondary);
    font-size: 0.88rem;
    line-height: 1.7;
    margin-bottom: 28px;
}

.start-btn {
    background: var(--gradient-main);
    color: white;
    border: none;
    padding: 14px 36px;
    border-radius: var(--radius-xl);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-md);
    font-family: var(--font-main);
}

.start-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.btn-arrow {
    transition: transform var(--transition-fast);
}

.start-btn:hover .btn-arrow {
    transform: translateX(4px);
}

/* Message Bubbles */
.message {
    display: flex;
    gap: 10px;
    max-width: 80%;
    animation: messageIn 0.3s ease;
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

.message.assistant {
    align-self: flex-start;
}

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
}

.message.user .message-avatar {
    background: var(--accent-blue);
    border: none;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    font-size: 0.88rem;
    line-height: 1.75;
    white-space: pre-wrap;
    word-break: break-word;
}

.message.assistant .message-bubble {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-top-left-radius: 4px;
    color: var(--text-primary);
}

.message.user .message-bubble {
    background: var(--gradient-main);
    color: white;
    border-top-right-radius: 4px;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 10px;
    align-self: flex-start;
    max-width: 80%;
    animation: messageIn 0.3s ease;
}

.typing-dots {
    display: flex;
    gap: 4px;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    border-top-left-radius: 4px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {

    0%,
    80%,
    100% {
        transform: scale(0.6);
        opacity: 0.4;
    }

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

/* Generate Button (shown after interview) */
.generate-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 24px;
    animation: messageIn 0.5s ease;
}

.generate-btn {
    background: var(--gradient-warm);
    color: white;
    border: none;
    padding: 16px 40px;
    border-radius: var(--radius-xl);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-md);
    font-family: var(--font-main);
}

.generate-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

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

.generate-label {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* Chat Input */
.chat-input-area {
    padding: 16px 24px;
    border-top: 1px solid var(--glass-border);
    background: var(--bg-secondary);
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: var(--bg-input);
    border-radius: var(--radius-lg);
    padding: 8px 12px;
    border: 1px solid var(--glass-border);
    transition: border-color var(--transition-fast);
}

.input-wrapper:focus-within {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(91, 138, 245, 0.1);
}

#message-input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 0.88rem;
    font-family: var(--font-main);
    resize: none;
    max-height: 120px;
    line-height: 1.5;
    padding: 6px 4px;
    outline: none;
}

#message-input::placeholder {
    color: var(--text-muted);
}

.send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--gradient-main);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    flex-shrink: 0;
    opacity: 0.5;
}

.send-btn:not(:disabled) {
    opacity: 1;
}

.send-btn:not(:disabled):hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-glow);
}

.send-btn:disabled {
    cursor: not-allowed;
}

/* ===========================
   Article Panel
   =========================== */
.article-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.article-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--glass-border);
    background: var(--bg-secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.article-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.back-btn {
    background: none;
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: var(--font-main);
}

.back-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.article-header h2 {
    font-size: 0.95rem;
    font-weight: 600;
}

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

.action-btn {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: var(--font-main);
}

.action-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent-blue);
}

.article-content {
    flex: 1;
    overflow-y: auto;
    padding: 32px 48px;
    font-size: 0.92rem;
    line-height: 2;
    color: var(--text-primary);
}

.article-content::-webkit-scrollbar {
    width: 4px;
}

.article-content::-webkit-scrollbar-thumb {
    background: var(--bg-hover);
    border-radius: 2px;
}

.article-content h1 {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 24px;
    background: var(--gradient-main);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.article-content h2 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-top: 36px;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid rgba(91, 138, 245, 0.2);
    color: var(--accent-blue);
}

.article-content p {
    margin-bottom: 8px;
}

.article-content blockquote {
    border-left: 3px solid var(--accent-purple);
    padding: 12px 20px;
    margin: 16px 0;
    background: rgba(155, 114, 242, 0.06);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-secondary);
    font-style: italic;
}

.article-content strong {
    color: var(--accent-pink);
    font-weight: 600;
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 15, 20, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    gap: 20px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--bg-hover);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-text {
    font-size: 0.92rem;
    color: var(--text-secondary);
}

.loading-sub {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: -12px;
}

/* Toast notification */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--bg-card);
    border: 1px solid var(--accent-green);
    color: var(--text-primary);
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-size: 0.82rem;
    box-shadow: var(--shadow-lg);
    animation: slideInToast 0.3s ease, fadeOut 0.3s ease 2.5s forwards;
    z-index: 2000;
}

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

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

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateY(10px);
    }
}

/* ===========================
   Selection Panel
   =========================== */
.selection-panel {
    display: flex;
    /* 初期状態ではJSで制御されるがflex定義 */
    flex-direction: column;
    gap: 2rem;
    padding: 1rem;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    animation: fadeIn 0.3s ease;
}

.selection-header {
    text-align: center;
    margin-bottom: 1rem;
}

.selection-header h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.selection-header p {
    color: var(--text-secondary);
}

.selection-step h3 {
    font-size: 1.2rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
    border-left: 4px solid var(--accent-color);
    padding-left: 0.8rem;
}

.cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
}

.selection-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.2rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.selection-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    border-color: var(--text-secondary);
}

.selection-card.selected {
    border-color: var(--accent-color);
    background-color: rgba(139, 92, 246, 0.1);
    /* accent-color with opacity */
    box-shadow: 0 0 0 2px var(--accent-color);
}

.card-title {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--accent-color);
}

.card-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.card-example {
    font-size: 0.85rem;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.05);
    padding: 0.5rem;
    border-radius: 6px;
    margin-top: auto;
    /* 下寄せ */
    font-style: italic;
}

.selection-actions {
    display: flex;
    justify-content: center;
    margin-top: 2rem;
}

.final-generate-btn {
    background: linear-gradient(135deg, var(--accent-color), var(--secondary-color));
    color: white;
    border: none;
    padding: 1rem 3rem;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.final-generate-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.4);
}

.final-generate-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    background: var(--border-color);
}

/* ===========================
   Responsive
   =========================== */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        position: fixed;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        height: 100vh;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        height: 100vh;
    }

    .mobile-menu-btn {
        display: block;
    }

    .cards-container {
        grid-template-columns: 1fr;
        /* スマホでは縦積み */
    }

    .message {
        max-width: 90%;
    }

    .article-content {
        padding: 20px 16px;
    }

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

/* ===========================
   Wizard UI
   =========================== */
.wizard-step {
    animation: fadeIn 0.4s ease;
}

.wizard-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    gap: 1rem;
    color: var(--text-secondary);
    animation: fadeIn 0.3s ease;
}

.loading-spinner-small {
    width: 30px;
    height: 30px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.back-btn-wizard {
    background: none;
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    padding: 0.8rem 2rem;
    border-radius: 50px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.back-btn-wizard:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

#wizard-title {
    transition: all 0.3s ease;
}

#wizard-desc {
    transition: all 0.3s ease;
}