:root {
    --font-serif: 'Cormorant Garamond', serif;
    --font-sans: 'Zen Kaku Gothic New', sans-serif;
    --color-bg: #fcfcfc;
    --color-text: #333;
    --color-accent: #8b7d7b;
    --spacing: 24px;
}

body {
    margin: 0;
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing);
    position: sticky;
    top: 0;
    background: rgba(252, 252, 252, 0.9);
    backdrop-filter: blur(5px);
    z-index: 100;
}

.logo {
    font-family: var(--font-serif);
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: 0.05em;
}

nav a {
    text-decoration: none;
    color: var(--color-text);
    margin-left: var(--spacing);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.hero {
    text-align: center;
    padding: 80px 20px;
}

.hero h1 {
    font-family: var(--font-serif);
    font-size: 3rem;
    margin-bottom: 10px;
    font-weight: 400;
}


.chat-series-link {
    color: #4a4a4a;
    text-decoration: underline;
    cursor: pointer;
    pointer-events: auto;
}

/* Wizard */
.wizard-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.wizard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    padding-bottom: 12px;
}

.wizard-progress {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    letter-spacing: 0.05em;
}

.wizard-remaining {
    font-size: 0.85rem;
    color: #777;
    letter-spacing: 0.04em;
}

.wizard-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.wizard-actions button,
.wizard-actions a {
    border: 1px solid #ddd;
    background: white;
    padding: 6px 14px;
    border-radius: 999px;
    text-decoration: none;
    color: var(--color-text);
    font-size: 0.85rem;
}

.wizard-step {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.wizard-card {
    background: #fff;
    border: 1px solid #eee;
    border-radius: 14px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.wizard-card h3 {
    margin: 0;
    font-family: var(--font-serif);
    font-weight: 500;
}

.wizard-filter {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.wizard-filter textarea {
    flex: 1 1 320px;
    min-height: 80px;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 10px;
    font-family: var(--font-sans);
}

.wizard-filter button {
    border: 1px solid #ddd;
    background: var(--color-accent);
    color: white;
    padding: 10px 18px;
    border-radius: 10px;
    cursor: pointer;
}

.wizard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 18px;
}

.wizard-series-groups {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.wizard-series-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.wizard-series-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #2f2b29;
}

.wizard-item {
    border: 1px solid #eee;
    border-radius: 14px;
    overflow: visible;
    background: #fff;
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.wizard-item.selected {
    border-color: #8b7d7b;
    box-shadow: 0 0 0 2px rgba(139, 125, 123, 0.2);
}

.wizard-item:hover {
    border-color: #8f9ea0;
    box-shadow: 0 10px 26px rgba(31, 41, 45, 0.12);
    transform: translateY(-2px);
}

.wizard-item img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    object-position: top;
    background: #f1f1f1;
    border-radius: 14px 14px 0 0;
}

.wizard-item-media {
    position: relative;
}

.wizard-item-bubble {
    position: absolute;
    left: 50%;
    bottom: 100%;
    transform: translate(calc(-50% + var(--bubble-shift, 0px)), -10px);
    display: flex;
    gap: 8px;
    padding: 8px;
    border-radius: 12px;
    background: #fff;
    border: 1px solid #ddd;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 2;
}

.wizard-item-bubble::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 100%;
    transform: translateX(-50%);
    border: 8px solid transparent;
    border-top-color: #fff;
}

.wizard-item-bubble img {
    width: auto;
    height: 360px;
    border-radius: 8px;
    object-fit: contain;
    background: #f6f6f6;
}

.wizard-item-media:hover .wizard-item-bubble {
    opacity: 1;
    transform: translate(calc(-50% + var(--bubble-shift, 0px)), -16px);
}

.wizard-selected-img {
    width: 180px;
    height: 180px;
    object-fit: contain;
    object-position: top;
    border-radius: 10px;
    background: #f4f4f4;
}

.wizard-item-body {
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.wizard-item-title {
    font-weight: 600;
}

.wizard-item-link {
    color: inherit;
    text-decoration: none;
}

.wizard-item-link:hover {
    text-decoration: underline;
}

.wizard-item-id {
    font-size: 0.85rem;
    color: #8c8682;
}

.wizard-item-tagline {
    font-size: 0.85rem;
    color: #666;
}

.wizard-item-action {
    margin-top: 6px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 999px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 0.85rem;
}

.wizard-story-cta {
    width: 100%;
    background: #6e5d58;
    color: #fff;
    border: none;
    font-size: 1rem;
    padding: 12px 16px;
}

.wizard-contact-section {
    background: #fff;
    border: 1px solid #eee;
    border-radius: 14px;
    padding: 18px;
}

.wizard-story-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.wizard-story {
    background: #fff;
    border: 1px solid #eee;
    border-radius: 14px;
    padding: 18px;
    white-space: pre-wrap;
}

.wizard-story-name {
    font-family: var(--font-serif);
    font-size: 1.6rem;
    margin-bottom: 10px;
}

.wizard-contact-btn {
    display: inline-block;
    margin-top: 14px;
    padding: 10px 18px;
    border-radius: 999px;
    border: 1px solid #ddd;
    background: var(--color-accent);
    color: white;
    text-decoration: none;
    font-size: 0.9rem;
}

/* Chat */
.chat-page-container {
    height: calc(100vh - 100px);
    /* Adjust based on main header */
    display: flex;
    flex-direction: column;
    max-width: 800px;
    margin: 0 auto;
}

.chat-page-header {
    text-align: center;
    padding: 10px;
    background: var(--color-bg);
}

.chat-page-header h2 {
    margin: 0;
    font-size: 1.2rem;
    font-family: var(--font-serif);
}

.chat-usage {
    margin-top: 6px;
    font-size: 0.85rem;
    color: #777;
    letter-spacing: 0.04em;
}

.interaction-area button:disabled,
.interaction-area textarea:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.chat-wrapper.expanded {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
    border: 1px solid #eee;
    border-radius: 8px;
    overflow: hidden;
    /* Ensure scroll matches */
    margin-bottom: 20px;
}

.chat-header {
    /* Legacy override or remove */
    display: none;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    padding: 12px 18px;
    border-radius: 12px;
    max-width: 80%;
    font-size: 0.95rem;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
    overflow: visible;
}

.message.assistant {
    background: #f5f5f5;
    align-self: flex-start;
    border-bottom-left-radius: 2px;
}

.message.user {
    background: var(--color-text);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}

.interaction-area {
    padding: 20px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
}

.interaction-area textarea {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: inherit;
    resize: none;
    height: 50px;
    /* Default height */
}

.interaction-area button {
    padding: 10px 20px;
    background: var(--color-text);
    color: white;
    border: none;
    cursor: pointer;
    height: 50px;
    /* Match textarea */
}

.chat-img {
    display: block;
    max-width: 100%;
    height: auto;
    margin-top: 10px;
    border-radius: 8px;
}

.chat-img-clickable {
    cursor: pointer;
}

.chat-selected {
    margin-top: 6px;
    font-size: 0.75rem;
    color: #777;
}
