/* 每日灵感 - 与 chat 一致的深色主题 */
:root {
    --insp-bg: #343541;
    --insp-surface: #40414f;
    --insp-surface-2: #2a2b32;
    --insp-border: #565869;
    --insp-text: #ececf1;
    --insp-muted: #8e8ea0;
    --insp-accent: #19c37d;
    --insp-danger: #f85149;
    --insp-max-width: 820px;
}

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

body.inspiration-page {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--insp-bg);
    color: var(--insp-text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 顶栏 — 复用 chat header 样式命名 */
.inspiration-header {
    height: 60px;
    background: var(--insp-bg);
    border-bottom: 1px solid var(--insp-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.inspiration-header__title-wrap {
    display: flex;
    align-items: baseline;
    gap: 12px;
    min-width: 0;
}

.inspiration-header__title {
    font-size: 16px;
    font-weight: 600;
    color: var(--insp-text);
    white-space: nowrap;
}

.inspiration-header__date {
    font-size: 13px;
    color: var(--insp-muted);
}

.header-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.header-btn {
    padding: 8px 16px;
    background: transparent;
    border: 1px solid var(--insp-border);
    border-radius: 6px;
    color: var(--insp-text);
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.header-btn:hover {
    background: var(--insp-surface);
}

.header-btn--danger {
    border-color: #fc8181;
    color: #feb2b2;
}

.header-btn--danger:hover {
    background: rgba(248, 81, 73, 0.12);
}

/* 主内容区 */
.inspiration-main {
    flex: 1;
    max-width: var(--insp-max-width);
    width: 100%;
    margin: 0 auto;
    padding: 16px 16px 120px;
}

.location-bar {
    background: var(--insp-surface);
    border: 1px solid var(--insp-border);
    border-radius: 12px;
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 24px;
    font-size: 13px;
    color: var(--insp-text);
}

.location-bar.is-error {
    border-color: rgba(248, 81, 73, 0.5);
    background: rgba(248, 81, 73, 0.08);
    color: #feb2b2;
}

.location-bar.is-loading {
    color: var(--insp-muted);
}

.location-icon {
    flex-shrink: 0;
}

.location-text {
    flex: 1;
    line-height: 1.4;
    word-break: break-all;
}

.location-refresh {
    border: none;
    background: none;
    cursor: pointer;
    font-size: 16px;
    opacity: 0.8;
    padding: 4px;
}

.location-refresh:hover {
    opacity: 1;
}

/* 时间轴树杈布局 */
.timeline {
    position: relative;
    min-height: 200px;
}

.timeline.empty::after {
    content: '今天还没有记录，在下方捕捉灵感 ✨';
    display: block;
    text-align: center;
    color: var(--insp-muted);
    padding: 80px 20px;
    font-size: 15px;
    line-height: 1.6;
}

.timeline-track {
    position: relative;
    padding: 8px 0 24px;
}

.timeline-track::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--insp-border);
    transform: translateX(-50%);
    border-radius: 1px;
}

.timeline-node {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 72px minmax(0, 1fr);
    align-items: start;
    margin-bottom: 28px;
    position: relative;
}

.timeline-node--left .timeline-card-slot:first-child {
    grid-column: 1;
    justify-self: end;
    padding-right: 10px;
}

.timeline-node--left .timeline-marker {
    grid-column: 2;
}

.timeline-node--left .timeline-card-slot--ghost {
    grid-column: 3;
}

.timeline-node--right .timeline-card-slot--ghost {
    grid-column: 1;
}

.timeline-node--right .timeline-marker {
    grid-column: 2;
}

.timeline-node--right .timeline-card-slot:first-child {
    grid-column: 3;
    justify-self: start;
    padding-left: 10px;
}

.timeline-marker {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 2;
    padding-top: 4px;
}

.timeline-time {
    font-size: 11px;
    color: var(--insp-muted);
    margin-bottom: 6px;
    white-space: nowrap;
    background: var(--insp-bg);
    padding: 0 4px;
}

.timeline-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--insp-accent);
    border: 2px solid var(--insp-bg);
    box-shadow: 0 0 0 2px var(--insp-border);
    flex-shrink: 0;
}

.timeline-branch {
    position: absolute;
    top: 28px;
    height: 2px;
    width: 24px;
    background: var(--insp-border);
}

.timeline-node--left .timeline-branch {
    right: calc(50% + 5px);
}

.timeline-node--right .timeline-branch {
    left: calc(50% + 5px);
}

.timeline-card-slot {
    width: 100%;
    max-width: 320px;
    min-width: 0;
    padding: 0 8px;
    overflow: hidden;
}

.timeline-card {
    background: var(--insp-surface);
    border: 1px solid var(--insp-border);
    border-radius: 12px;
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
    touch-action: manipulation;
    -webkit-touch-callout: none;
    user-select: none;
    -webkit-user-select: none;
    max-width: 100%;
}

.timeline-card:hover {
    border-color: #6b6c7b;
}

.timeline-card.is-selected {
    border-color: var(--insp-accent);
    box-shadow: 0 0 0 1px rgba(25, 195, 125, 0.25);
}

.timeline-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-bottom: 1px solid #4d4e57;
    font-size: 12px;
}

.timeline-card__type {
    color: var(--insp-muted);
    font-weight: 500;
}

.timeline.is-selection-mode .timeline-card__body img,
.timeline.is-selection-mode .timeline-card__body video {
    pointer-events: none;
}

.timeline-card__body {
    padding: 10px 12px 12px;
    font-size: 14px;
    line-height: 1.5;
}

.timeline-card__text {
    color: var(--insp-text);
    word-break: break-word;
    margin: 0;
}

.timeline-card__meta {
    font-size: 12px;
    color: var(--insp-muted);
    margin: 6px 0 0;
}

.timeline-card__link {
    display: inline-block;
    margin-top: 6px;
    color: var(--insp-accent);
    text-decoration: none;
    font-size: 13px;
}

.timeline-card__link:hover {
    text-decoration: underline;
}

.timeline-card__media {
    max-width: 100%;
    border-radius: 8px;
    display: block;
}

.timeline-card__body img,
.timeline-card__body video,
.timeline-card__body audio {
    max-width: 100%;
    border-radius: 8px;
    display: block;
    -webkit-touch-callout: none;
}

.timeline-card__location {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed #4d4e57;
    font-size: 12px;
    color: var(--insp-muted);
}

.timeline-card__location-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.timeline-card__location-link {
    flex-shrink: 0;
    color: var(--insp-accent);
    text-decoration: none;
}

.timeline-card__location-link:hover {
    text-decoration: underline;
}

/* 底部复合输入 */
.inspiration-composer-wrap {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: linear-gradient(to top, var(--insp-bg) 70%, transparent);
    z-index: 200;
}

.inspiration-composer {
    max-width: var(--insp-max-width);
    margin: 0 auto;
    background: var(--insp-surface);
    border: 1px solid var(--insp-border);
    border-radius: 28px;
    overflow: hidden;
    transition: border-color 0.2s, border-radius 0.2s;
}

.inspiration-composer.is-text-mode {
    border-radius: 14px;
}

.inspiration-composer:focus-within {
    border-color: #8e8ea0;
}

.insp-composer-text {
    display: none;
    width: 100%;
    min-height: 72px;
    max-height: 160px;
    padding: 14px 16px 8px;
    background: transparent;
    border: none;
    color: var(--insp-text);
    font-size: 15px;
    outline: none;
    resize: none;
    font-family: inherit;
    line-height: 1.5;
}

.inspiration-composer.is-text-mode .insp-composer-text {
    display: block;
}

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

.insp-composer-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 12px;
}

.inspiration-composer.is-text-mode .insp-composer-actions {
    border-top: 1px solid #4d4e57;
    padding: 6px 10px 8px;
}

.insp-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s;
}

.insp-icon-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.06);
}

.insp-icon-btn img {
    display: block;
    filter: invert(0.92);
    opacity: 0.95;
}

.insp-icon-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.insp-icon-btn.is-active {
    background: rgba(25, 195, 125, 0.12);
}

.insp-icon-btn.is-active img {
    filter: invert(0.92) sepia(1) saturate(3) hue-rotate(90deg);
}

.insp-voice-hold {
    flex: 1;
    min-width: 0;
    height: 40px;
    border: none;
    background: transparent;
    color: var(--insp-text);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 20px;
    transition: background 0.15s, color 0.15s;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

.insp-voice-hold:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.05);
}

.insp-voice-hold.is-recording {
    background: rgba(248, 81, 73, 0.15);
    color: #feb2b2;
    animation: insp-pulse 1.2s infinite;
}

.insp-icon-btn.is-recording {
    background: rgba(248, 81, 73, 0.15);
}

.insp-icon-btn.is-recording img {
    filter: invert(0.7) sepia(1) saturate(5) hue-rotate(320deg);
}

@keyframes insp-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.75; }
}

.inspiration-composer.is-busy {
    opacity: 0.85;
    pointer-events: none;
}

.hidden-input {
    display: none;
}

/* Toast — 与 chat.css 一致 */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: var(--insp-surface-2);
    border: 1px solid #40414f;
    border-radius: 8px;
    padding: 12px 20px;
    min-width: 250px;
    max-width: 400px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    gap: 12px;
    pointer-events: auto;
    animation: insp-slide-in 0.3s ease-out;
    color: var(--insp-text);
    font-size: 14px;
}

.toast.success { border-left: 4px solid var(--insp-accent); }
.toast.error { border-left: 4px solid var(--insp-danger); }
.toast.info { border-left: 4px solid #58a6ff; }
.toast.warning { border-left: 4px solid #f0ad4e; }

.toast-icon { font-size: 20px; flex-shrink: 0; }
.toast.success .toast-icon { color: var(--insp-accent); }
.toast.error .toast-icon { color: var(--insp-danger); }

.toast.hiding {
    animation: insp-slide-out 0.3s ease-in forwards;
}

@keyframes insp-slide-in {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes insp-slide-out {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

@media (max-width: 640px) {
    .inspiration-header {
        padding: 0 12px;
    }

    .header-actions {
        gap: 6px;
    }

    .header-btn {
        padding: 8px 10px;
        font-size: 13px;
        white-space: nowrap;
    }

    body.is-selection-mode .inspiration-header__title {
        display: none;
    }

    .timeline-node {
        grid-template-columns: minmax(0, 1fr) 32px minmax(0, 1fr);
        margin-bottom: 22px;
    }

    .timeline-card-slot {
        max-width: calc(50vw - 28px);
        padding: 0 2px;
    }

    .timeline-node--left .timeline-card-slot:first-child {
        padding-right: 8px;
    }

    .timeline-node--right .timeline-card-slot:first-child {
        padding-left: 8px;
    }

    .timeline-branch {
        width: 10px;
    }

    .timeline-time {
        font-size: 10px;
    }

    .timeline-dot {
        width: 8px;
        height: 8px;
    }

    .inspiration-header__title {
        font-size: 15px;
    }

    .inspiration-header__date {
        display: none;
    }
}

@media (max-width: 420px) {
    .timeline-node {
        grid-template-columns: minmax(0, 1fr) 28px minmax(0, 1fr);
    }

    .timeline-card-slot {
        max-width: calc(50vw - 24px);
    }

    .insp-voice-hold {
        font-size: 14px;
    }

    .insp-icon-btn {
        width: 36px;
        height: 36px;
    }
}
