/* FC Daily Diary — modern, mobile-first styling
   Every class name below is referenced by the plugin's JS/PHP — do not
   rename classes when customizing, only adjust values/tokens. */

/* ---------------------------------------------------------------------
 * Isolation reset. Some hosting environments load frameworks with very
 * assertive global styling (Bootstrap 5, used by KiviCare; or a heavily
 * custom theme like Discy) that reset raw elements (button, ul, h1-h6,
 * input, a) site-wide. Everything in this block is scoped to .fcd-portal
 * and re-establishes a neutral baseline BEFORE the plugin's own component
 * rules below apply, so those rules don't have to fight inherited
 * defaults element-by-element.
 * ---------------------------------------------------------------------*/
.fcd-portal,
.fcd-portal * {
    box-sizing: border-box;
}

.fcd-portal button {
    box-sizing: border-box;
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    background: none;
    border: none;
    margin: 0;
    padding: 0;
    -webkit-appearance: none;
    appearance: none;
    text-align: inherit;
    line-height: normal;
}

.fcd-portal input,
.fcd-portal select,
.fcd-portal textarea {
    all: revert;
    box-sizing: border-box;
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
}

.fcd-portal ul,
.fcd-portal ol {
    list-style: none;
    margin: 0;
    padding: 0;
}

.fcd-portal h1,
.fcd-portal h2,
.fcd-portal h3,
.fcd-portal h4,
.fcd-portal p {
    margin: 0;
    padding: 0;
    font-weight: inherit;
    font-size: inherit;
    line-height: inherit;
}

.fcd-portal a {
    text-decoration: none;
    color: inherit;
}

.fcd-portal img {
    max-width: none;
}

.fcd-portal {
    --fcd-bg: #ffffff;
    --fcd-surface: #f6f7fb;
    --fcd-surface-2: #eef0f7;
    --fcd-border: #ecedf5;
    --fcd-text: #171923;
    --fcd-muted: #6b7280;
    --fcd-primary: #5b5bf0;
    --fcd-primary-dark: #4644d6;
    --fcd-primary-contrast: #ffffff;
    --fcd-danger: #ef4444;
    --fcd-like: #ec4899;
    --fcd-radius-lg: 20px;
    --fcd-radius-md: 14px;
    --fcd-radius-sm: 10px;
    --fcd-shadow: 0 1px 2px rgba(20, 20, 43, 0.04), 0 8px 24px -12px rgba(20, 20, 43, 0.12);
    --fcd-shadow-sm: 0 1px 2px rgba(20, 20, 43, 0.06);
    --fcd-ease: cubic-bezier(0.4, 0, 0.2, 1);

    max-width: 720px;
    margin: 16px auto;
    padding: 0;
    background: var(--fcd-bg);
    color: var(--fcd-text);
    border-radius: var(--fcd-radius-lg);
    box-shadow: var(--fcd-shadow);
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
    line-height: 1.5;
    -webkit-tap-highlight-color: transparent;
}

/* Elements that mix plain text with emoji glyphs: force an emoji-capable
   fallback explicitly. Some host themes set a custom webfont site-wide
   that has no emoji glyphs and doesn't reliably fall back, leaving emoji
   invisible instead of showing a placeholder. */
.fcd-mood,
.fcd-app-header h1,
.fcd-tab,
.fcd-habit-name,
.fcd-habit-hint,
.fcd-preset-btn,
.fcd-habit-emoji-input,
#fcd-habit-emoji,
.fcd-habit-check-icon,
.fcd-count-step,
.fcd-like-icon,
.fcd-empty-icon {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji" !important;
}

@media (prefers-color-scheme: dark) {
    .fcd-portal {
        --fcd-bg: #16171d;
        --fcd-surface: #1f2028;
        --fcd-surface-2: #262834;
        --fcd-border: #2b2d38;
        --fcd-text: #f0f1f5;
        --fcd-muted: #9599a8;
        --fcd-shadow: 0 1px 2px rgba(0, 0, 0, 0.2), 0 8px 24px -12px rgba(0, 0, 0, 0.5);
    }
}
/* If your theme toggles dark mode via a body/html class instead of the OS
   setting, duplicate the block above scoped to e.g. body.fcom-dark .fcd-portal */

* {
    -webkit-tap-highlight-color: transparent;
}

.fcd-portal button {
    font-family: inherit;
    transition: transform 0.12s var(--fcd-ease), background-color 0.15s var(--fcd-ease), border-color 0.15s var(--fcd-ease), opacity 0.15s var(--fcd-ease);
}

.fcd-portal button:active {
    transform: scale(0.96);
}

.fcd-login-notice {
    text-align: center;
    padding: 48px 24px;
    color: var(--fcd-muted);
    font-size: 1rem;
}

/* ===================== Header + Tabs ===================== */

.fcd-app-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 18px 20px 14px;
    background: var(--fcd-bg);
    border-bottom: 1px solid var(--fcd-border);
}

.fcd-app-header::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 2px;
    background: linear-gradient(90deg, var(--fcd-primary), var(--fcd-like), var(--fcd-primary));
    opacity: 0.6;
}

.fcd-app-header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin: 0;
}

.fcd-tabs {
    display: flex;
    gap: 2px;
    background: var(--fcd-surface);
    border-radius: 999px;
    padding: 4px;
    width: 100%;
}

@media (max-width: 640px) {
    .fcd-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .fcd-tabs::-webkit-scrollbar {
        display: none;
    }
    .fcd-tab {
        flex: 0 0 auto !important;
    }
}

.fcd-tab {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--fcd-muted);
    padding: 10px 14px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
}

.fcd-tab.is-active {
    background: var(--fcd-bg);
    color: var(--fcd-primary);
    box-shadow: var(--fcd-shadow-sm), inset 0 -2px 0 var(--fcd-primary);
}

.fcd-tab-icon {
    margin-right: 4px;
}

.fcd-tabpanel {
    display: none;
    padding: 18px 20px 24px;
    animation: fcd-fade-in 0.2s var(--fcd-ease);
}

.fcd-tabpanel.is-active {
    display: block;
}

@keyframes fcd-fade-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ===================== My Diary tab ===================== */

.fcd-date-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-bottom: 18px;
    background: var(--fcd-surface);
    border-radius: var(--fcd-radius-sm);
    padding: 6px;
}

.fcd-date-nav input[type="date"] {
    flex: 1;
    padding: 9px 10px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--fcd-text);
    font-size: 0.94rem;
    font-weight: 600;
    text-align: center;
}

.fcd-layout {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 20px;
}

@media (max-width: 640px) {
    .fcd-layout {
        grid-template-columns: 1fr;
    }
    .fcd-sidebar {
        order: 2;
    }
    .fcd-editor-pane {
        order: 1;
    }
}

.fcd-sidebar h2 {
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--fcd-muted);
    margin: 4px 0 10px;
}

.fcd-entry-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 420px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.fcd-entry-list li {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 6px;
    padding: 10px 8px 10px 12px;
    border-radius: var(--fcd-radius-sm);
    cursor: pointer;
    font-size: 0.92rem;
    border: 1px solid transparent;
    transition: background-color 0.15s var(--fcd-ease);
}

.fcd-entry-list-text {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.fcd-entry-list li:hover {
    background: var(--fcd-surface);
}

.fcd-entry-list li.is-active {
    background: var(--fcd-surface-2);
    border-color: var(--fcd-primary);
}

.fcd-entry-list .fcd-entry-date {
    display: block;
    font-weight: 600;
    margin-bottom: 2px;
}

.fcd-entry-list .fcd-entry-excerpt {
    display: block;
    color: var(--fcd-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.88rem;
}

.fcd-empty-note {
    color: var(--fcd-muted);
    font-size: 0.92rem;
    padding: 24px 16px;
    text-align: center;
    line-height: 1.5;
}

.fcd-empty-icon {
    display: block;
    font-size: 1.8rem;
    margin-bottom: 8px;
}

/* Reusable ⋮ (kebab) menu - used anywhere a delete/edit action needs to be
   tucked away from an exposed edge, so it can't be triggered by an
   accidental tap while scrolling on mobile. */
.fcd-kebab {
    position: relative;
    flex-shrink: 0;
}

#fcd-app .fcd-kebab-btn {
    flex-shrink: 0 !important;
    box-sizing: border-box !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 32px !important;
    height: 32px !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    border-radius: 8px !important;
    background: transparent !important;
    color: var(--fcd-muted) !important;
    font-size: 1.15rem !important;
    font-weight: 700;
    line-height: 1 !important;
    cursor: pointer !important;
}

#fcd-app .fcd-kebab-btn:hover,
#fcd-app .fcd-kebab.is-open .fcd-kebab-btn {
    background: var(--fcd-surface-2) !important;
    color: var(--fcd-text) !important;
}

.fcd-kebab-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    z-index: 30;
    min-width: 130px;
    background: var(--fcd-bg);
    border: 1px solid var(--fcd-border);
    border-radius: var(--fcd-radius-sm);
    box-shadow: var(--fcd-shadow);
    padding: 6px;
    flex-direction: column;
    gap: 2px;
}

.fcd-kebab.is-open .fcd-kebab-menu {
    display: flex;
}

#fcd-app .fcd-kebab-item {
    text-align: left;
    background: none !important;
    border: none;
    border-radius: 8px;
    padding: 9px 10px;
    font-size: 0.88rem;
    color: var(--fcd-text) !important;
    cursor: pointer;
    width: 100%;
}

#fcd-app .fcd-kebab-item.is-danger {
    color: var(--fcd-danger) !important;
}

.fcd-kebab-item:hover {
    background: var(--fcd-surface);
}

.fcd-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
}

.fcd-mood-picker {
    display: flex;
    gap: 2px;
    background: var(--fcd-surface);
    border-radius: 999px;
    padding: 4px;
    flex-wrap: wrap;
}

.fcd-mood {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: none;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--fcd-muted);
    padding: 8px 10px;
    min-height: 36px;
    cursor: pointer;
    line-height: 1;
    white-space: nowrap;
}

.fcd-mood-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    background: var(--fcd-border);
}

.fcd-mood[data-mood="great"] .fcd-mood-dot { background: #22c55e; }
.fcd-mood[data-mood="good"]  .fcd-mood-dot { background: #84cc16; }
.fcd-mood[data-mood="okay"]  .fcd-mood-dot { background: #eab308; }
.fcd-mood[data-mood="low"]   .fcd-mood-dot { background: #f97316; }
.fcd-mood[data-mood="rough"] .fcd-mood-dot { background: #ef4444; }

.fcd-mood:hover {
    background: var(--fcd-surface-2);
}

.fcd-mood.is-selected {
    background: var(--fcd-bg);
    color: var(--fcd-text);
    box-shadow: var(--fcd-shadow-sm);
}

.fcd-share-toggle {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.9rem;
    color: var(--fcd-muted);
    cursor: pointer;
}

.fcd-share-toggle input {
    width: 17px;
    height: 17px;
    accent-color: var(--fcd-primary);
}

.fcd-textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--fcd-border);
    border-radius: var(--fcd-radius-md);
    background: var(--fcd-surface);
    color: var(--fcd-text);
    padding: 16px;
    font-size: 16px; /* prevents iOS auto-zoom */
    line-height: 1.6;
    resize: vertical;
    min-height: 180px;
    transition: border-color 0.15s var(--fcd-ease), background-color 0.15s var(--fcd-ease);
}

.fcd-textarea:focus {
    outline: none;
    border-color: var(--fcd-primary);
    background: var(--fcd-bg);
}

.fcd-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

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

.fcd-status {
    font-size: 0.88rem;
    color: var(--fcd-muted);
    min-height: 1.2em;
}

.fcd-status.is-error {
    color: var(--fcd-danger);
    font-weight: 600;
}

.fcd-privacy-hint {
    font-size: 0.84rem;
    color: var(--fcd-muted);
    margin-top: 12px;
    line-height: 1.5;
}

/* ===================== Buttons ===================== */

.fcd-btn {
    border: 1px solid var(--fcd-border);
    background: var(--fcd-surface);
    color: var(--fcd-text);
    padding: 10px 16px;
    min-height: 40px;
    border-radius: var(--fcd-radius-sm);
    cursor: pointer;
    font-size: 0.92rem;
    font-weight: 600;
}

.fcd-btn:hover {
    filter: brightness(0.97);
}

.fcd-btn-ghost {
    background: transparent;
    border-color: transparent;
    font-size: 1.15rem;
    padding: 6px 12px;
    min-height: auto;
    color: var(--fcd-muted);
}

.fcd-btn-primary {
    background: linear-gradient(135deg, var(--fcd-primary), var(--fcd-primary-dark));
    border-color: var(--fcd-primary);
    color: var(--fcd-primary-contrast);
    box-shadow: 0 3px 10px -3px rgba(91, 91, 240, 0.55);
}

.fcd-btn-primary:hover {
    filter: brightness(1.05);
}

.fcd-btn-outline {
    background: transparent;
    border-color: var(--fcd-primary);
    color: var(--fcd-primary);
}

.fcd-btn-danger {
    background: transparent;
    border-color: var(--fcd-danger);
    color: var(--fcd-danger);
}

.fcd-btn[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none !important;
}

/* ===================== Community Feed tab ===================== */

.fcd-feed {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.fcd-feed-card {
    border: 1px solid var(--fcd-border);
    border-radius: var(--fcd-radius-md);
    padding: 16px;
    background: var(--fcd-surface);
    box-shadow: var(--fcd-shadow-sm);
    animation: fcd-fade-in 0.25s var(--fcd-ease);
}

.fcd-feed-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.fcd-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 0 0 2px var(--fcd-bg);
}

.fcd-avatar-sm {
    width: 28px;
    height: 28px;
}

.fcd-feed-author {
    display: block;
    font-weight: 700;
    font-size: 0.94rem;
}

.fcd-feed-date {
    display: block;
    font-size: 0.82rem;
    color: var(--fcd-muted);
    margin-top: 1px;
}

.fcd-feed-content {
    white-space: pre-wrap;
    line-height: 1.65;
    margin: 0 0 14px;
    font-size: 0.96rem;
}

.fcd-feed-card-footer {
    display: flex;
    gap: 18px;
    border-top: 1px solid var(--fcd-border);
    padding-top: 10px;
}

.fcd-like-btn,
.fcd-comment-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.92rem;
    color: var(--fcd-muted);
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 2px;
    font-weight: 600;
    transition: transform 0.12s var(--fcd-ease), color 0.15s var(--fcd-ease);
}

.fcd-like-btn:active {
    transform: scale(1.25);
}

.fcd-like-btn.is-liked {
    color: var(--fcd-like);
}

.fcd-comments {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--fcd-border);
}

.fcd-comment-list {
    list-style: none;
    margin: 0 0 10px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.fcd-comment {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.fcd-comment-author {
    font-weight: 700;
    font-size: 0.86rem;
    display: block;
}

.fcd-comment-content {
    margin: 2px 0 0;
    font-size: 0.92rem;
    line-height: 1.5;
}

.fcd-comment-form {
    display: flex;
    gap: 8px;
}

.fcd-comment-input {
    flex: 1;
    min-width: 0;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 1px solid var(--fcd-border);
    border-radius: 999px;
    background: var(--fcd-bg);
    color: var(--fcd-text);
    font-size: 16px;
}

.fcd-comment-input:focus {
    outline: none;
    border-color: var(--fcd-primary);
}

.fcd-comment-form .fcd-btn {
    border-radius: 999px;
    padding: 10px 18px;
}

.fcd-feed-footer {
    text-align: center;
    margin-top: 18px;
}

/* ===================== Habits tab ===================== */

.fcd-habit-hint {
    font-size: 0.9rem;
    color: var(--fcd-muted);
    margin: 0 0 14px;
    line-height: 1.5;
}

.fcd-habit-stats {
    display: flex;
    align-items: center;
    gap: 18px;
    background: var(--fcd-surface);
    border-radius: var(--fcd-radius-md);
    padding: 14px 16px;
    margin-bottom: 16px;
}

.fcd-stat {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.fcd-stat-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--fcd-primary);
    line-height: 1.2;
}

.fcd-stat-label {
    font-size: 0.72rem;
    color: var(--fcd-muted);
    white-space: nowrap;
}

.fcd-stat-bar-wrap {
    flex: 1;
    min-width: 40px;
}

.fcd-stat-bar {
    height: 8px;
    border-radius: 999px;
    background: var(--fcd-border);
    overflow: hidden;
}

.fcd-stat-bar-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--fcd-primary), var(--fcd-like));
    transition: width 0.3s var(--fcd-ease);
}

.fcd-habit-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 22px;
}

.fcd-habit-card {
    border: 1px solid var(--fcd-border);
    border-left: 3px solid var(--fcd-primary);
    border-radius: var(--fcd-radius-md);
    padding: 14px 16px;
    background: var(--fcd-surface);
    box-shadow: var(--fcd-shadow-sm);
    transition: box-shadow 0.15s var(--fcd-ease), transform 0.15s var(--fcd-ease);
    animation: fcd-fade-in 0.25s var(--fcd-ease);
}

.fcd-habit-card:active {
    transform: scale(0.995);
}

.fcd-habit-main {
    display: flex;
    align-items: center;
    gap: 12px;
}

#fcd-app .fcd-habit-check {
    pointer-events: auto !important;
    cursor: pointer !important;
    flex-shrink: 0 !important;
    box-sizing: border-box !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 50% !important;
    border: 2px solid var(--fcd-primary) !important;
    background: transparent !important;
    color: var(--fcd-primary-contrast);
    font-weight: 700;
    font-size: 1rem !important;
    line-height: 1 !important;
}

#fcd-app .fcd-habit-check.is-done {
    background: var(--fcd-primary) !important;
}

.fcd-habit-check-icon {
    pointer-events: none;
}

.fcd-habit-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.fcd-habit-name {
    font-weight: 700;
    font-size: 0.98rem;
}

.fcd-habit-meta {
    font-size: 0.84rem;
    color: var(--fcd-muted);
    margin-top: 1px;
}

.fcd-habit-delete {
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    opacity: 0.5;
    padding: 10px;
    min-width: 40px;
    min-height: 40px;
}

.fcd-habit-delete:hover {
    opacity: 1;
}

.fcd-habit-strip {
    display: flex;
    gap: 3px;
    margin-top: 12px;
}

.fcd-strip-day {
    flex: 1;
    height: 7px;
    border-radius: 4px;
    background: var(--fcd-border);
    transition: background-color 0.15s var(--fcd-ease);
}

.fcd-strip-day:last-child {
    box-shadow: 0 0 0 2px var(--fcd-surface), 0 0 0 3px var(--fcd-primary);
}

.fcd-strip-day.is-done {
    background: var(--fcd-primary);
}

.fcd-strip-day.is-missed {
    background: transparent;
    border: 1px solid var(--fcd-danger);
    opacity: 0.6;
}

.fcd-strip-day.is-off {
    background: transparent;
    border: 1px dashed var(--fcd-border);
}

.fcd-habit-form {
    border-top: 1px solid var(--fcd-border);
    padding-top: 20px;
}

.fcd-habit-form h3 {
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--fcd-muted);
    margin: 0 0 12px;
}

.fcd-habit-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.fcd-preset-btn {
    flex: 1 1 auto;
    white-space: nowrap;
}

.fcd-habit-type-row {
    margin-bottom: 14px;
}

.fcd-habit-unit-input {
    box-sizing: border-box;
    width: 100%;
    margin-top: 8px;
    padding: 10px 12px;
    border: 1px solid var(--fcd-border);
    border-radius: var(--fcd-radius-sm);
    background: var(--fcd-surface);
    color: var(--fcd-text);
    font-size: 16px;
}

.fcd-habit-unit-input:focus {
    outline: none;
    border-color: var(--fcd-primary);
    background: var(--fcd-bg);
}

/* Count-type habit stepper (e.g. "ayahs recited today") - a dedicated
   full-width row below the name/delete row, not squeezed inline with
   variable-length text. */
#fcd-app .fcd-count-control {
    display: flex !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
    gap: 8px !important;
    width: 100% !important;
    height: 40px !important;
    max-height: 40px !important;
    min-height: 40px !important;
    box-sizing: border-box !important;
    background: var(--fcd-bg);
    border: 1px solid var(--fcd-border);
    border-radius: var(--fcd-radius-sm);
    padding: 4px 10px;
    margin-top: 10px;
    overflow: hidden !important;
}

.fcd-count-label {
    flex-shrink: 0;
    font-size: 0.86rem;
    color: var(--fcd-muted);
    font-weight: 600;
}

#fcd-app .fcd-count-step {
    flex-shrink: 0 !important;
    box-sizing: border-box !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 30px !important;
    height: 30px !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    border-radius: 50% !important;
    background: var(--fcd-surface) !important;
    color: var(--fcd-primary) !important;
    font-size: 1.15rem !important;
    font-weight: 700;
    line-height: 1 !important;
    cursor: pointer !important;
}

#fcd-app .fcd-count-step:hover {
    background: var(--fcd-surface-2) !important;
}

#fcd-app .fcd-count-input {
    flex: 1 1 auto !important;
    width: auto !important;
    min-width: 0 !important;
    height: 30px !important;
    max-height: 30px !important;
    line-height: 30px !important;
    box-sizing: border-box !important;
    text-align: center;
    border: none !important;
    background: transparent;
    color: var(--fcd-text);
    font-size: 1rem;
    font-weight: 700;
    padding: 0 !important;
    margin: 0 !important;
    -moz-appearance: textfield;
    -webkit-appearance: none;
    appearance: none;
}

.fcd-count-unit {
    flex-shrink: 0;
    font-size: 0.86rem;
    color: var(--fcd-muted);
}

.fcd-choice-control {
    display: flex;
    gap: 6px;
    margin-top: 10px;
    flex-wrap: wrap;
}

#fcd-app .fcd-choice-pill {
    flex: 1 1 0;
    min-width: 0;
    box-sizing: border-box !important;
    border: 1px solid var(--fcd-border) !important;
    background: var(--fcd-bg) !important;
    color: var(--fcd-muted) !important;
    padding: 9px 8px !important;
    border-radius: var(--fcd-radius-sm) !important;
    font-size: 0.78rem !important;
    font-weight: 600;
    cursor: pointer !important;
    text-align: center;
    white-space: nowrap;
}

#fcd-app .fcd-choice-pill.is-selected {
    background: var(--fcd-primary) !important;
    border-color: var(--fcd-primary) !important;
    color: var(--fcd-primary-contrast) !important;
}

.fcd-count-input::-webkit-outer-spin-button,
.fcd-count-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.fcd-count-input:focus {
    outline: none;
}

.fcd-habit-form-row {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.fcd-habit-emoji-input,
.fcd-habit-name-input,
.fcd-habit-form input[type="text"] {
    box-sizing: border-box;
    font-size: 16px; /* prevents iOS Safari auto-zoom on focus */
}

.fcd-habit-emoji-input {
    flex: 0 0 54px;
    width: 54px;
    text-align: center;
    padding: 11px 6px;
    border: 1px solid var(--fcd-border);
    border-radius: var(--fcd-radius-sm);
    background: var(--fcd-surface);
    color: var(--fcd-text);
}

.fcd-habit-name-input {
    flex: 1 1 0%;
    min-width: 0;
    padding: 11px 14px;
    border: 1px solid var(--fcd-border);
    border-radius: var(--fcd-radius-sm);
    background: var(--fcd-surface);
    color: var(--fcd-text);
}

.fcd-habit-emoji-input:focus,
.fcd-habit-name-input:focus {
    outline: none;
    border-color: var(--fcd-primary);
    background: var(--fcd-bg);
}

.fcd-habit-frequency {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    margin-bottom: 14px;
    font-size: 0.92rem;
}

.fcd-radio {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

#fcd-app .fcd-radio input[type="radio"],
#fcd-app .fcd-weekday-picker input[type="checkbox"] {
    -webkit-appearance: auto;
    appearance: auto;
    opacity: 1 !important;
    position: static !important;
    width: 17px;
    height: 17px;
    margin: 0;
    accent-color: var(--fcd-primary);
}

.fcd-weekday-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
    width: 100%;
    font-size: 0.88rem;
    color: var(--fcd-muted);
    background: var(--fcd-surface);
    border-radius: var(--fcd-radius-sm);
    padding: 12px;
    margin-top: 4px;
}

.fcd-weekday-picker label {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    padding: 4px 0;
}

.fcd-habit-form button[type="submit"],
#fcd-habit-submit {
    width: 100%;
    padding: 13px;
    min-height: 46px;
    font-size: 0.98rem;
    border-radius: var(--fcd-radius-sm);
    position: relative;
    z-index: 5; /* stay above any fixed bottom nav bar from the host theme */
}

#fcd-habit-status {
    margin-top: 10px;
    min-height: 1em;
}

@media (max-width: 380px) {
    .fcd-app-header {
        padding: 14px 14px 12px;
    }
    .fcd-app-header h1 {
        font-size: 1.1rem;
    }
    .fcd-tab {
        font-size: 0.84rem;
        padding: 9px 8px;
    }
    .fcd-tabpanel {
        padding: 14px 14px 20px;
    }
    .fcd-habit-card,
    .fcd-feed-card {
        padding: 12px;
    }
    .fcd-mood-picker {
        width: 100%;
        justify-content: space-between;
    }
    .fcd-mood {
        padding: 7px 5px;
        font-size: 0.7rem;
        gap: 3px;
    }
    .fcd-mood-dot {
        width: 8px;
        height: 8px;
    }
    .fcd-count-label,
    .fcd-count-unit {
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .fcd-habit-form-row {
        flex-wrap: wrap;
    }
    .fcd-habit-emoji-input {
        width: 100%;
        flex-basis: 100%;
    }
    .fcd-habit-name-input {
        width: 100%;
        flex-basis: 100%;
    }
}

@media (max-width: 782px) {
    .fcd-portal {
        margin: 0;
        border-radius: 0;
        /* Clears a fixed bottom mobile nav bar some community themes use,
           so the habit form / its button are never hidden underneath it. */
        padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px));
    }
}

/* Header icon injected into FluentCommunity's top menu via
   fluent_community/before_header_menu_items */
.fcd_header_link a {
    display: flex;
    align-items: center;
    gap: 4px;
}
.fcd_header_link_label {
    display: none;
}
@media (min-width: 960px) {
    .fcd_header_link_label {
        display: inline;
    }
}

.fcd-doctor-share-box {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px dashed var(--fcd-border);
}

/* ===================== Search ===================== */

.fcd-search-box {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
}

.fcd-search-box input[type="text"] {
    flex: 1;
    min-width: 0;
    box-sizing: border-box;
    padding: 9px 12px;
    border: 1px solid var(--fcd-border);
    border-radius: var(--fcd-radius-sm);
    background: var(--fcd-surface);
    color: var(--fcd-text);
    font-size: 16px;
}

.fcd-search-filters {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: var(--fcd-surface);
    border-radius: var(--fcd-radius-sm);
    padding: 10px;
    margin-bottom: 10px;
}

.fcd-search-filters input,
.fcd-search-filters select {
    box-sizing: border-box;
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--fcd-border);
    border-radius: 8px;
    background: var(--fcd-bg);
    color: var(--fcd-text);
    font-size: 0.85rem;
}

.fcd-search-actions {
    display: flex;
    gap: 6px;
}

.fcd-search-actions .fcd-btn {
    flex: 1;
}

/* ===================== Rich text editor ===================== */

.fcd-meta-row {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.fcd-meta-row select,
.fcd-meta-row input {
    flex: 1;
    min-width: 140px;
    box-sizing: border-box;
    padding: 9px 12px;
    border: 1px solid var(--fcd-border);
    border-radius: var(--fcd-radius-sm);
    background: var(--fcd-surface);
    color: var(--fcd-text);
    font-size: 16px;
}

.fcd-richtext-toolbar {
    display: flex;
    gap: 4px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}

.fcd-rt-btn {
    width: 34px;
    height: 34px;
    border: 1px solid var(--fcd-border);
    background: var(--fcd-surface);
    color: var(--fcd-text);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
}

.fcd-rt-btn:hover {
    background: var(--fcd-surface-2);
}

.fcd-richtext {
    min-height: 180px;
    outline: none;
    overflow-y: auto;
}

.fcd-richtext:empty::before {
    content: attr(data-placeholder);
    color: var(--fcd-muted);
}

.fcd-richtext h1, .fcd-richtext h2, .fcd-richtext h3 {
    margin: 0.6em 0 0.3em;
    font-size: 1.1em;
    font-weight: 700;
}

.fcd-richtext ul {
    margin: 0.4em 0;
    padding-left: 1.4em;
}

.fcd-richtext a {
    color: var(--fcd-primary);
    text-decoration: underline;
}

.fcd-richtext p {
    margin: 0 0 0.6em;
}

/* ===================== Habit weekly/monthly target ===================== */

.fcd-period-target {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    margin-top: 6px;
}

.fcd-period-target input {
    width: 60px;
    box-sizing: border-box;
    padding: 8px;
    border: 1px solid var(--fcd-border);
    border-radius: 8px;
    background: var(--fcd-surface);
    color: var(--fcd-text);
    font-size: 0.9rem;
    text-align: center;
}

.fcd-period-target span {
    font-size: 0.82rem;
    color: var(--fcd-muted);
}

/* ===================== To-Do board ===================== */

.fcd-todo-board {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    padding-bottom: 6px;
    margin-bottom: 18px;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 640px) {
    /* Stack lists full-width on mobile instead of horizontal scroll -
       avoids the swipe/scroll-vs-tap ambiguity that causes problems on
       small touchscreens. */
    .fcd-todo-board {
        flex-direction: column;
        overflow-x: visible;
    }
}

.fcd-todo-list {
    flex: 0 0 260px;
    display: flex;
    flex-direction: column;
    background: var(--fcd-surface);
    border: 1px solid var(--fcd-border);
    border-radius: var(--fcd-radius-md);
    padding: 12px;
    max-height: 70vh;
}

@media (max-width: 640px) {
    .fcd-todo-list {
        flex: 1 1 auto;
        max-height: none;
    }
}

.fcd-todo-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}

.fcd-todo-list-name {
    font-weight: 700;
    font-size: 0.92rem;
}

.fcd-todo-list-delete {
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.96rem;
    opacity: 0.5;
    padding: 8px;
    min-width: 36px;
    min-height: 36px;
}

.fcd-todo-list-delete:hover {
    opacity: 1;
}

.fcd-todo-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    margin-bottom: 10px;
}

.fcd-todo-card {
    background: var(--fcd-bg);
    border: 1px solid var(--fcd-border);
    border-left: 3px solid var(--fcd-primary);
    border-radius: var(--fcd-radius-sm);
    padding: 10px 12px;
    box-shadow: var(--fcd-shadow-sm);
    animation: fcd-fade-in 0.2s var(--fcd-ease);
}

.fcd-todo-card-title {
    font-size: 0.92rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    cursor: pointer;
    margin-bottom: 8px;
}

.fcd-todo-card-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

#fcd-app .fcd-todo-card-up,
#fcd-app .fcd-todo-card-down,
#fcd-app .fcd-todo-card-delete {
    flex-shrink: 0 !important;
    box-sizing: border-box !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 30px !important;
    height: 30px !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    border-radius: 8px !important;
    background: var(--fcd-surface) !important;
    color: var(--fcd-text) !important;
    font-size: 0.84rem !important;
    cursor: pointer !important;
}

.fcd-todo-card-up:hover,
.fcd-todo-card-down:hover,
.fcd-todo-card-delete:hover {
    background: var(--fcd-surface-2) !important;
}

.fcd-todo-card-up[disabled],
.fcd-todo-card-down[disabled] {
    opacity: 0.3;
    cursor: not-allowed !important;
}

.fcd-todo-card-move {
    flex: 1 1 auto;
    min-width: 90px;
    height: 30px;
    box-sizing: border-box;
    border: 1px solid var(--fcd-border);
    border-radius: 8px;
    background: var(--fcd-bg);
    color: var(--fcd-text);
    font-size: 0.82rem;
    padding: 0 6px;
}

.fcd-todo-card-edit {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid var(--fcd-primary);
    border-radius: 8px;
    padding: 8px;
    font-size: 16px;
    font-family: inherit;
    background: var(--fcd-bg);
    color: var(--fcd-text);
    resize: vertical;
    min-height: 60px;
    margin-top: 6px;
}

.fcd-todo-card-edit-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.fcd-todo-card-add {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.fcd-todo-card-add-input {
    flex: 1;
    min-width: 0;
    box-sizing: border-box;
    padding: 9px 10px;
    border: 1px solid var(--fcd-border);
    border-radius: 8px;
    background: var(--fcd-bg);
    color: var(--fcd-text);
    font-size: 16px;
}

.fcd-todo-card-add-input:focus {
    outline: none;
    border-color: var(--fcd-primary);
}

.fcd-todo-list-form {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.fcd-todo-list-form input[type="text"] {
    flex: 1;
    min-width: 160px;
    box-sizing: border-box;
    padding: 11px 14px;
    border: 1px solid var(--fcd-border);
    border-radius: var(--fcd-radius-sm);
    background: var(--fcd-surface);
    color: var(--fcd-text);
    font-size: 16px;
}

.fcd-todo-list-form input[type="text"]:focus {
    outline: none;
    border-color: var(--fcd-primary);
    background: var(--fcd-bg);
}

#fcd-todo-status {
    margin-top: 10px;
}
