:root {
    --bg-color: #f8fafc;
    --text-color: #0f172a;
    --text-muted: #64748b;
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(255, 255, 255, 0.8);
    --glass-blur: blur(12px);
}

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

body {
    font-family: 'Outfit', 'Noto Sans JP', sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

/* Background Animation */
.bg-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background:
        radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.08) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(56, 189, 248, 0.08) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.08) 0px, transparent 50%),
        radial-gradient(at 0% 100%, rgba(236, 72, 153, 0.08) 0px, transparent 50%);
    z-index: -1;
    pointer-events: none;
    will-change: transform;
}

/* Typography */
.gradient-text {
    background: linear-gradient(90deg, var(--primary), #38bdf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
}

.text-muted {
    color: var(--text-muted);
}

/* Utility */
.glass {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow:
        0 4px 6px -1px rgba(0, 0, 0, 0.03),
        0 10px 15px -3px rgba(0, 0, 0, 0.03),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.btn {
    padding: 12px 24px;
    font-size: 1rem;
    border: none;
    border-radius: 100px;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    letter-spacing: 0.5px;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.9rem;
    border-radius: 100px;
}

.btn-lg {
    min-height: 54px;
    padding: 15px 24px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #3b82f6);
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.4);
    filter: brightness(1.05);
}

.btn-secondary {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-color);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.btn-secondary:hover {
    background: rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.dropdown-item {
    background: none;
    border: none;
    padding: 10px;
    text-align: left;
    cursor: pointer;
    border-radius: 8px;
    width: 100%;
    transition: background 0.2s;
    font-family: inherit;
    font-weight: 600;
    color: #d9534f;
    font-size: 0.9rem;
}

.dropdown-item:hover {
    background: rgba(217, 83, 79, 0.1);
}

.w-full {
    width: 100%;
}

.mt-2 {
    margin-top: 0.5rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.text-sm {
    font-size: 0.875rem;
}

.opacity-70 {
    opacity: 0.7;
}

.hidden {
    display: none !important;
}

/* Navbar */
.navbar {
    position: fixed;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 64px);
    max-width: 1220px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 40px;
    z-index: 100;
    border-radius: 100px;
    white-space: nowrap;
}

.nav-right {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    margin-right: 0px;
}

.logo {
    font-size: 1.4rem;
    font-weight: 800;
    cursor: pointer;
    background: linear-gradient(45deg, var(--primary), #38bdf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    flex-shrink: 0;
    white-space: nowrap;
    letter-spacing: -0.5px;
}

.line-icon {
    width: 1.7em;
    height: 1.7em;
    flex-shrink: 0;
    vertical-align: middle;
    object-fit: contain;
}

/* Views */
.view {
    display: none;
    padding-top: 120px;
    min-height: 100vh;
    padding-bottom: 50px;
    width: 90%;
    max-width: 1175px;
    margin: 0 auto;
    animation: fadeIn 0.5s ease;
}

.view.active {
    display: block;
}

#view-editor.active {
    display: flex;
    flex-direction: column;
    padding: 0;
    width: 90%;
    max-width: 1200px;
    height: 100vh;
    overflow: hidden;
    margin: 0 auto;
}

#view-home.active {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    max-width: none;
    padding: 60px 0 30px;
    width: 100%;
}

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

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

@keyframes slideUpFade {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

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

/* Home */
.home-hero {
    align-items: center;
    display: flex;
    min-height: 720px;
    overflow: hidden;
    padding: 16px max(32px, calc((100vw - 1180px) / 2)) 32px;
    position: relative;
    width: 100%;
}

body::before {
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.78), rgba(248, 250, 252, 0.28)),
        linear-gradient(115deg, rgba(99, 102, 241, 0.12), transparent 44%),
        linear-gradient(250deg, rgba(20, 184, 166, 0.14), transparent 46%);
    content: "";
    inset: 0;
    position: fixed;
    z-index: -2;
    pointer-events: none;
}

body::after {
    background-image:
        linear-gradient(rgba(15, 23, 42, 0.055) 1px, transparent 1px),
        linear-gradient(90deg, rgba(15, 23, 42, 0.055) 1px, transparent 1px);
    background-size: 44px 44px;
    content: "";
    inset: 0;
    mask-image: linear-gradient(90deg, rgba(0, 0, 0, 0.52), transparent 74%);
    position: fixed;
    z-index: -1;
    pointer-events: none;
}

.hero-copy {
    max-width: 46%;
    position: relative;
    z-index: 2;
}

.eyebrow {
    color: var(--primary);
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    margin-bottom: 18px;
}

.hero-copy h1 {
    color: #0b1220;
    font-size: clamp(2rem, 3.8vw, 3.8rem);
    letter-spacing: 0;
    line-height: 1.18;
    margin-bottom: 26px;
    white-space: nowrap;
}

.hero-lead {
    color: #475569;
    font-size: 1.16rem;
    font-weight: 600;
    line-height: 1.9;
    max-width: 620px;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 34px;
}

.home-visual {
    inset: 0;
    pointer-events: none;
    position: absolute;
    z-index: 1;
}

.site-window {
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.9);
    border-radius: 18px;
    box-shadow: 0 34px 90px rgba(15, 23, 42, 0.16);
    overflow: hidden;
    position: absolute;
}

.site-window-main {
    height: 430px;
    right: max(40px, calc((100vw - 1180px) / 2));
    top: 92px;
    transform: rotate(-4deg);
    width: min(48vw, 560px);
}

.site-window-side {
    bottom: 84px;
    height: 250px;
    right: max(70px, calc((100vw - 1040px) / 2));
    transform: rotate(5deg);
    width: min(34vw, 380px);
}

.window-bar {
    align-items: center;
    background: rgba(248, 250, 252, 0.84);
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    display: flex;
    gap: 7px;
    height: 38px;
    padding: 0 14px;
}

.window-bar span {
    background: #cbd5e1;
    border-radius: 50%;
    height: 9px;
    width: 9px;
}

.window-bar span:first-child {
    background: #fb7185;
}

.window-bar span:nth-child(2) {
    background: #facc15;
}

.window-bar span:nth-child(3) {
    background: #34d399;
}

.window-hero {
    background:
        linear-gradient(135deg, rgba(99, 102, 241, 0.9), rgba(14, 165, 233, 0.76)),
        linear-gradient(18deg, transparent 56%, rgba(255, 255, 255, 0.2) 57% 76%, transparent 77%),
        linear-gradient(155deg, transparent 42%, rgba(255, 255, 255, 0.16) 43% 62%, transparent 63%);
    background-size: cover;
    border-radius: 14px;
    height: 190px;
    margin: 18px;
}

.window-lines {
    display: grid;
    gap: 12px;
    margin: 0 22px;
}

.window-lines span {
    background: rgba(100, 116, 139, 0.24);
    border-radius: 999px;
    height: 12px;
}

.window-lines span:first-child {
    width: 78%;
}

.window-lines span:nth-child(2) {
    width: 56%;
}

.window-lines span:nth-child(3) {
    width: 68%;
}

.window-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(3, 1fr);
    margin: 24px 22px 0;
}

.window-grid i {
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.12);
    border-radius: 12px;
    height: 62px;
}

.chat-preview-row,
.chat-preview-reply {
    border-radius: 18px;
    height: 42px;
    margin: 22px 24px 0;
}

.chat-preview-row {
    background: rgba(100, 116, 139, 0.16);
    width: 72%;
}

.chat-preview-row.short {
    width: 52%;
}

.chat-preview-reply {
    background: linear-gradient(135deg, #06c755, #22c55e);
    margin-left: auto;
    width: 64%;
}

.home-highlights {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-top: -44px;
    padding: 20px max(24px, calc((100vw - 1180px) / 2));
    position: relative;
    width: 100%;
    z-index: 3;
}

.highlight-item {
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(255, 255, 255, 0.92);
    border-radius: 16px;
    box-shadow: 0 22px 54px rgba(15, 23, 42, 0.08);
    min-height: 164px;
    padding: 24px;
}

.highlight-item span {
    color: var(--primary);
    display: block;
    font-size: 0.85rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    margin-bottom: 12px;
}

.highlight-item strong {
    color: #0f172a;
    display: block;
    font-size: 1.2rem;
    margin-bottom: 7px;
}

.highlight-item p {
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1.75;
}

/* AI Editor Chat */
.editor-chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.editor-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.1) transparent;
}

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

.editor-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
}

.message {
    display: flex;
    gap: 12px;
    max-width: 100%;
    animation: messageSlideUp 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

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

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

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

.editor-avatar {
    width: 34px;
    height: 34px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

/* AI Avatar styles are now handled in .editor-avatar.ai-avatar */

.user-avatar {
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.user-avatar img {
    width: 100%;
    height: 100%;
    border-radius: inherit;
    object-fit: cover;
}

.bubble {
    padding: 12px 16px;
    font-size: 0.95rem;
    line-height: 1.5;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
}


.editor-input-area {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 8px 8px 8px 16px;
    border-radius: 16px;
    border: 1px solid rgba(99, 102, 241, 0.2);
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.6) !important;
}

.editor-input-area:focus-within {
    background: white !important;
    border-color: var(--primary);
    box-shadow: 0 8px 30px rgba(99, 102, 241, 0.12);
    transform: translateY(-2px);
}

.editor-input-area textarea {
    flex: 1;
    background: none;
    border: none;
    padding: 8px 0;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-color);
    resize: none;
    outline: none;
    max-height: 150px;
    line-height: 1.5;
}

.editor-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.editor-send-btn:hover {
    transform: scale(1.05) translateY(-2px);
    background: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.editor-send-btn:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
    transform: none;
}

.editor-input-hint {
    margin-top: 10px;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    opacity: 0.8;
}

/* Dashboard */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
}

.project-card {
    background: rgba(255, 255, 255, 0.8);
    padding: 0;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(255, 255, 255, 1);
    cursor: pointer;
    display: block;
    overflow: hidden;
    text-align: left;
    position: relative;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, transform 0.2s ease;
    width: 100%;
    font: inherit;
    color: inherit;
}

.project-card::after {
    display: none;
    /* 外部のラインを消して、内側のシャドウに統合 */
}

.project-card:hover {
    background: rgba(255, 255, 255, 0.95);
    box-shadow:
        0 12px 30px rgba(99, 102, 241, 0.12),
        inset 0 3px 0 rgba(99, 102, 241, 0.2),
        inset 0 1px 12px rgba(99, 102, 241, 0.05);
    border-color: rgba(99, 102, 241, 0.3);
    transform: translateY(-6px);
}

/* ::after は削除済み */

.project-card h3,
.project-title-input {
    color: var(--text-color);
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.45;
    margin: 0;
}

.project-card h3 {
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.project-title-input {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    display: block;
    font-family: inherit;
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-color);
    outline: none;
    padding: 6px 0;
    transition: all 0.2s ease;
    width: 100%;
    cursor: text;
}

.project-title-edit {
    margin: -2px 0 6px;
    position: relative;
}

.project-title-edit:hover .project-title-input {
    background: rgba(255, 255, 255, 0.5);
    border-color: rgba(99, 102, 241, 0.1);
    padding-left: 10px;
}

.project-title-input:focus {
    background: white;
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.08);
    padding-left: 10px;
}

.project-card-body {
    padding: 12px 20px 20px;
}

.project-card-header {
    margin-bottom: 4px;
    display: flex;
    justify-content: flex-end;
}

.project-date {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 600;
    opacity: 0.6;
    letter-spacing: 0.02em;
}

.project-card-meta {
    align-items: center;
    color: var(--text-muted);
    display: flex;
    font-size: 0.78rem;
    gap: 12px;
    justify-content: space-between;
    min-height: 28px;
    padding: 0 12px;
}

.project-publish-inline {
    align-items: center;
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    font-weight: 600;
    gap: 7px;
    min-height: 26px;
    padding: 2px 0;
    margin-left: 5px;
}

.project-publish-inline:hover {
    color: var(--text-color);
}

.project-publish-inline input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.mini-toggle {
    background: rgba(100, 116, 139, 0.28);
    border-radius: 999px;
    display: inline-block;
    height: 18px;
    position: relative;
    transition: background 0.2s ease;
    width: 34px;
}

.mini-toggle::after {
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.18);
    content: "";
    height: 14px;
    left: 2px;
    position: absolute;
    top: 2px;
    transform: translateX(0);
    transition: transform 0.2s ease;
    width: 14px;
}

.project-publish-inline input:checked+.mini-toggle {
    background: var(--primary);
}

.project-publish-inline input:checked+.mini-toggle::after {
    transform: translateX(16px);
}

.project-publish-inline input:focus-visible+.mini-toggle {
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.18);
}

.btn:disabled {
    cursor: not-allowed;
    filter: grayscale(0.2);
    opacity: 0.6;
    transform: none;
}

.project-preview {
    --project-preview-scale: 1;
    aspect-ratio: 16 / 10;
    background: #f8fafc;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    cursor: pointer;
    overflow: hidden;
    position: relative;
}

.project-preview iframe {
    pointer-events: none;
    border: none;
    width: 100%;
    height: 100%;
    transform-origin: top left;
    transform: scale(var(--project-preview-scale, 1));
}

.project-preview::before {
    background:
        linear-gradient(100deg, transparent 30%, rgba(255, 255, 255, 0.75) 50%, transparent 70%),
        linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(56, 189, 248, 0.08));
    background-size: 220% 100%, 100% 100%;
    content: "";
    inset: 0;
    opacity: 1;
    position: absolute;
    transition: opacity 0.18s ease;
    z-index: 1;
    animation: preview-loading-sheen 1.1s ease-in-out infinite;
}

.project-preview.is-preview-ready::before,
.project-preview.has-no-preview::before {
    opacity: 0;
    pointer-events: none;
}

@keyframes preview-loading-sheen {
    from {
        background-position: 140% 0, 0 0;
    }

    to {
        background-position: -80% 0, 0 0;
    }
}

.toast-container {
    bottom: 24px;
    display: grid;
    gap: 10px;
    justify-items: end;
    max-width: calc(100vw - 32px);
    position: fixed;
    right: 24px;
    z-index: 1200;
}

.toast {
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-left: 4px solid #22c55e;
    border-radius: 10px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.16);
    color: var(--text-color);
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.4;
    max-width: min(380px, calc(100vw - 32px));
    opacity: 1;
    padding: 12px 14px 12px 13px;
    transform: translateY(0);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.error {
    border-left-color: #ef4444;
    color: #991b1b;
}

.toast.is-hiding {
    opacity: 0;
    transform: translateY(8px);
}

.project-preview:focus-visible {
    outline: 3px solid rgba(99, 102, 241, 0.35);
    outline-offset: -3px;
}

.project-preview iframe {
    border: 0;
    height: 100%;
    left: 0;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
    position: absolute;
    top: 0;
    transform: scale(var(--project-preview-scale));
    transform-origin: top left;
    transition: opacity 0.16s ease;
    width: 100%;
}

.project-preview.is-preview-ready iframe {
    opacity: 1;
}

.project-preview-placeholder {
    align-items: center;
    color: var(--text-color);
    display: flex;
    font-size: 0.9rem;
    height: 100%;
    justify-content: center;
    opacity: 0.5;
}

.project-card .date {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Editor */
.editor-layout {
    display: flex;
    gap: 16px;
    flex: 1;
    min-height: 0;
    padding: 12px 16px 16px;
    margin-top: 100px;
    /* navbar height offset */
}

.btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: inherit;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(15, 23, 42, 0.1);
    border-radius: 100px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    letter-spacing: 0.3px;
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(99, 102, 241, 0.3);
    color: var(--text-color);
    transform: translateY(-1px);
}

.editor-sidebar {
    width: 380px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    padding: 0;
    gap: 16px;
    background: none;
    border: none;
}

.editor-project-settings {
    padding: 20px;
}

.project-settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 42px;
}

.editor-sidebar-header {
    padding: 24px 20px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.editor-sidebar-header h3 {
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--text-muted);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

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

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



.editor-preview {
    flex: 1;
    overflow: hidden;
    min-width: 0;
    /* Remove glass effect for performance as it's covered by the iframe */
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: rgba(255, 255, 255, 0.3);
    position: relative;
    /* For mask positioning */
}

#preview-frame {
    width: 100%;
    height: 100%;
    border: none;
    background: #fff;
    border-radius: 16px;
}

/* Preview Loader Overlay */
.preview-loader-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 16px;
}

.editor-preview.is-loading .preview-loader-overlay {
    opacity: 1;
    pointer-events: auto;
}

.preview-spinner {
    width: 42px;
    height: 42px;
    border: 3.5px solid rgba(99, 102, 241, 0.1);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 0.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    margin-bottom: 16px;
    filter: drop-shadow(0 4px 12px rgba(99, 102, 241, 0.2));
}

.preview-loading-text {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: 0.05em;
}

.editor-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scrollbar-width: none;
}

.editor-chat-messages::-webkit-scrollbar {
    display: none;
}

.editor-chat-messages .message {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    max-width: 100%;
}

.editor-chat-messages .message.user {
    flex-direction: row-reverse;
}

.editor-avatar {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}


.editor-avatar.ai-avatar {
    background: linear-gradient(135deg, var(--primary), #38bdf8);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-family: 'Outfit', sans-serif;
    font-weight: 800;
    font-size: 0.75rem;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    justify-content: center;
}

.editor-avatar.user-avatar {
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.editor-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: none;
}

.editor-avatar.ai-avatar svg {
    width: 20px;
    height: 20px;
}

.editor-chat-messages .bubble {
    padding: 12px 16px;
    font-size: 0.9rem;
    background: white;
    border: 1px solid rgba(15, 23, 42, 0.05);
    color: var(--text-color);
    line-height: 1.6;
    white-space: pre-wrap;
    max-width: calc(100% - 48px);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.02);
    position: relative;
    transition: all 0.2s ease;
    border-bottom-left-radius: 18px;
    border-bottom-right-radius: 18px;
}

.message.assistant .bubble {
    border-top-right-radius: 18px;
}

.message.user .bubble {
    background: linear-gradient(135deg, var(--primary), #4f46e5);
    color: white;
    border-color: transparent;
    border-top-left-radius: 18px;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.15);
}


.editor-input-wrapper {
    padding: 12px 16px 20px;
}

.editor-input-area {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 6px 6px 14px;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background: #f8fafc !important;
    transition: all 0.2s ease;
}

.editor-input-area:focus-within {
    border-color: var(--primary);
    background: white !important;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.1);
}

.editor-input-area textarea {
    flex: 1;
    background: none;
    border: none;
    padding: 10px 0;
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text-color);
    resize: none;
    outline: none;
    max-height: 120px;
    line-height: 1.4;
}

.editor-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.editor-send-btn:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.editor-send-btn:disabled {
    background: #e2e8f0;
    color: #94a3b8;
    cursor: not-allowed;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 20px;
}

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

/* Navbar User Group */
.nav-user-group {
    display: flex;
    align-items: center;
    gap: 24px;
    flex-shrink: 0;
    white-space: nowrap;
}

.nav-divider {
    width: 1px;
    height: 20px;
    background: rgba(0, 0, 0, 0.1);
}

.user-menu-container {
    position: relative;
}

.user-menu-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    transition: background 0.2s;
}

.user-menu-trigger:hover {
    background: rgba(0, 0, 0, 0.05);
}

.user-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.dropdown-arrow {
    font-size: 0.7rem;
    color: #888;
}

.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 10px;
    padding: 8px;
    min-width: 150px;
    text-align: left;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.96) !important;
    backdrop-filter: blur(20px) !important;
    border-color: rgba(0, 0, 0, 0.1) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1) !important;
}

.logout-btn {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 10px 12px;
    color: #ef4444;
    /* Red color for logout */
    font-weight: 700;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.08);
}

.empty-state-container {
    text-align: center;
    padding: 50px 30px;
    width: 100%;
    max-width: 600px;
    margin: 40px auto;
    grid-column: 1 / -1;
    opacity: 0;
    animation: slideUpFade 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.2s forwards;
}

/* Responsive Design (Mobile) */
@media (max-width: 768px) {
    .navbar {
        top: 10px;
        width: 95%;
        padding: 12px 20px 12px 25px;
        border-radius: 30px;
    }

    body.editor-page .navbar,
    body.editor-page .bg-animation {
        display: none !important;
    }

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

    .logo {
        font-size: 1.25rem;
    }

    .nav-user-group {
        gap: 8px;
    }

    .user-name {
        display: none;
        /* Hide name on mobile to save space */
    }

    .btn {
        padding: 10px 16px;
        font-size: 0.9rem;
    }

    .btn-sm {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    #view-home.active {
        padding: 140px 0 20px;
    }

    /* Project title input static on mobile with border and shifted position */
    .project-title-input {
        transition: none !important;
        padding-left: 10px !important;
        background: rgba(255, 255, 255, 0.5) !important;
        border-color: rgba(99, 102, 241, 0.1) !important;
    }

    .project-title-edit:hover .project-title-input,
    .project-title-input:focus {
        /* Keep the same design on hover/focus for mobile */
        box-shadow: none !important;
    }

    .home-hero {
        align-items: flex-start;
        flex-direction: column;
        min-height: auto;
        padding: 56px 20px 36px;
    }

    .home-hero::after {
        background-size: 34px 34px;
        mask-image: linear-gradient(rgba(0, 0, 0, 0.42), transparent 70%);
    }

    .hero-copy {
        display: contents;
    }

    .eyebrow,
    .hero-copy h1,
    .hero-lead {
        order: 1;
        position: relative;
        z-index: 2;
    }

    .eyebrow {
        line-height: 1.6;
        margin-bottom: 14px;
    }

    .hero-copy h1 {
        font-size: 2.1rem;
        line-height: 1.18;
        margin-bottom: 20px;
    }

    .hero-lead {
        font-size: 0.98rem;
        line-height: 1.8;
    }

    .home-visual {
        position: relative;
        inset: auto;
        width: 100%;
        height: 250px;
        opacity: 0.25;
        order: 2;
        margin: -100px 0 40px;
    }

    .hero-actions {
        order: 3;
        width: 100%;
        gap: 10px;
        margin-top: 0;
    }

    .hero-actions .btn {
        width: auto;
        flex: 1;
        font-size: 0.95rem;
        white-space: nowrap;
    }

    .site-window-main {
        height: 210px;
        right: -96px;
        top: 18px;
        width: 310px;
    }

    .site-window-side {
        bottom: 16px;
        height: 150px;
        right: 102px;
        width: 210px;
    }

    .window-bar {
        height: 26px;
        padding: 0 10px;
    }

    .window-bar span {
        height: 7px;
        width: 7px;
    }

    .window-hero {
        height: 82px;
        margin: 12px;
    }

    .window-lines {
        gap: 8px;
        margin: 0 14px;
    }

    .window-lines span {
        height: 8px;
    }

    .window-grid {
        gap: 8px;
        margin: 14px 14px 0;
    }

    .window-grid i {
        height: 36px;
    }

    .chat-preview-row,
    .chat-preview-reply {
        height: 26px;
        margin: 16px 16px 0;
    }

    .home-highlights {
        grid-template-columns: 1fr;
        margin-top: 20px;
        padding: 0 20px;
    }

    .highlight-item {
        min-height: 0;
        padding: 20px;
    }

    .project-grid {
        grid-template-columns: 1fr;
    }

    .project-preview {
        aspect-ratio: 1 / 1 !important;
    }

    #view-editor.active {
        height: 100vh !important;
        width: 100% !important;
        max-width: none !important;
        padding: 0 !important;
        margin: 0 !important;
        overflow: hidden !important;
    }

    .editor-layout {
        flex-direction: column;
        margin-top: 0 !important;
        gap: 0 !important;
        padding: 0 !important;
        height: 100vh !important;
    }

    .editor-preview {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 1;
        border-radius: 0 !important;
        border: none !important;
        background: #fff !important;
    }

    .preview-loader-overlay {
        border-radius: 0 !important;
    }

    #preview-frame {
        border-radius: 0 !important;
    }

    .editor-sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        z-index: 100;
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        backdrop-filter: none !important;
    }

    .editor-project-settings {
        display: none !important;
    }

    .editor-chat-container {
        background: none !important;
        border: none !important;
        box-shadow: none !important;
        backdrop-filter: none !important;
        padding: 0 !important;
    }

    .editor-sidebar-header {
        display: flex !important;
        position: fixed;
        top: 10px;
        left: 10px;
        right: 10px;
        z-index: 101;
        background: transparent !important;
        border: none !important;
        padding: 0 !important;
        pointer-events: none;
        margin-bottom: 0 !important;
    }

    .editor-sidebar-header h3 {
        display: none;
    }

    .editor-sidebar-actions {
        display: flex !important;
        justify-content: center;
        width: 100%;
        pointer-events: none;
        gap: 8px;
    }

    .editor-sidebar-actions .btn,
    .editor-sidebar-actions a {
        pointer-events: auto;
        background: rgba(255, 255, 255, 0.85) !important;
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        font-size: 0.8rem;
        padding: 8px 12px;
    }

    .editor-chat-messages {
        display: none !important;
    }

    .editor-input-wrapper {
        padding: 0 !important;
    }

    .editor-input-area {
        background: rgba(255, 255, 255, 0.95) !important;
        backdrop-filter: blur(20px) !important;
        -webkit-backdrop-filter: blur(20px) !important;
        border: 1px solid rgba(99, 102, 241, 0.2) !important;
        border-radius: 16px !important;
        padding: 6px 6px 6px 12px !important;
        margin: 0 8px calc(8px + env(safe-area-inset-bottom)) !important;
        display: flex !important;
        align-items: flex-end !important;
        gap: 10px !important;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08) !important;
        transition: none !important;
        pointer-events: auto !important;
    }

    .editor-input-area:focus-within {
        background: white !important;
        border-color: var(--primary) !important;
        box-shadow: 0 12px 40px rgba(99, 102, 241, 0.15) !important;
        transform: none !important;
    }

    .editor-input-area textarea {
        flex: 1 !important;
        background: none !important;
        border: none !important;
        padding: 8px 0 !important;
        font-family: inherit !important;
        font-size: 16px !important;
        color: var(--text-color) !important;
        resize: none !important;
        outline: none !important;
        max-height: 120px !important;
        line-height: 1.5 !important;
        min-height: auto !important;
        overflow-y: hidden !important;
        box-shadow: none !important;
        transition: none !important;
    }

    .editor-input-area textarea:focus {
        border-color: transparent !important;
    }

    .editor-input-area .editor-send-btn {
        width: 38px !important;
        height: 38px !important;
        border-radius: 12px !important;
        background: var(--primary) !important;
        color: white !important;
        border: none !important;
        cursor: pointer !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        transition: none !important;
        flex-shrink: 0 !important;
        box-shadow: none !important;
        transform: none !important;
    }

    .editor-input-area .editor-send-btn svg {
        width: 18px !important;
        height: 18px !important;
        margin-left: -1px !important;
        margin-top: 2px !important;
    }

    .editor-input-area .editor-send-btn:hover {
        transform: none !important;
    }

    .editor-input-area .editor-send-btn:active {
        transform: none !important;
    }


    .editor-input-area .editor-send-btn:disabled {
        opacity: 0.5;
        background: #94a3b8 !important;
        box-shadow: none !important;
        pointer-events: none;
    }


    .empty-state-container {
        padding: 30px 20px;
    }
}

@media (max-width: 600px) {
    .hero-actions {
        flex-direction: column;
    }

    .hero-actions .btn {
        width: 100%;
    }
}