* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: #f6f7fb;
    color: #2f3340;
}

.page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 20px 48px;
}

.page-header h1 {
    margin: 0 0 8px;
    font-size: 32px;
    font-weight: 700;
}

.page-header p {
    margin: 0 0 24px;
    color: #5e6577;
    font-size: 15px;
}

.amelia-account-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
    margin-bottom: 20px;
    padding: 12px 14px;
    background: #eef1f8;
    border-radius: 12px;
    border: 1px solid #dde3f0;
}

.amelia-account-email {
    font-size: 14px;
    color: #3d4456;
    margin-right: auto;
}

.auth-panel {
    max-width: 440px;
    margin: 0 auto;
    background: #fff;
    border: 1px solid #e3e7ef;
    border-radius: 16px;
    padding: 24px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

.auth-form label {
    font-size: 14px;
    font-weight: 600;
    color: #3d4456;
}

.auth-links {
    margin-top: 20px;
    font-size: 14px;
    color: #5e6577;
}

.auth-links a {
    color: #3b5bdb;
}

.auth-success {
    font-size: 15px;
    color: #2f3340;
    line-height: 1.5;
}

.main-layout {
    display: grid;
    grid-template-columns: 1fr 1.1fr;
    gap: 24px;
}

.panel {
    background: #ffffff;
    border: 1px solid #e3e7ef;
    border-radius: 16px;
    padding: 20px;
}

.panel-header h2 {
    margin: 0 0 8px;
    font-size: 22px;
    font-weight: 700;
}

.panel-header p {
    margin: 0 0 18px;
    color: #5e6577;
    font-size: 14px;
}

.add-grocery-item-btn {
    padding: 8px 12px;
    font-size: 13px;
}

.full-width {
    width: 100%;
}

.button-row {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.primary-btn,
.secondary-btn,
.ghost-btn {
    border: none;
    border-radius: 12px;
    padding: 12px 16px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
}

.primary-btn {
    background: #8d2342;
    color: white;
}

.secondary-btn {
    background: #edf1f8;
    color: #2f3340;
}

.ghost-btn {
    background: transparent;
    color: #556073;
    border: 1px solid #d8deeb;
}

.recipe-list {
    margin-bottom: 16px;
}

.recipe-card,
.loaded-recipe-card,
.error-item {
    border: 1px solid #e3e7ef;
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 14px;
    background: #fbfcff;
}

.recipe-card-top {
    margin-bottom: 10px;
}

.recipe-label {
    font-weight: 700;
    font-size: 15px;
}

.recipe-card label {
    display: block;
    font-size: 14px;
    margin-bottom: 6px;
    color: #4e5567;
}

.recipe-card input[type="text"] {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid #ccd3e0;
    border-radius: 10px;
    font-size: 14px;
}

.autocomplete-dropdown {
    position: absolute;
    z-index: 50;
    margin: 0;
    max-height: 260px;
    overflow-y: auto;
    background: #ffffff;
    border: 1px solid #ccd3e0;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(47, 51, 64, 0.12);
}

.autocomplete-item {
    padding: 10px 12px;
    font-size: 14px;
    cursor: pointer;
    color: #2f3340;
    border-bottom: 1px solid #eef1f6;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
    background: #f0f4fb;
}

.loaded-recipes,
.error-block {
    margin-top: 24px;
}

.loaded-recipes h3,
.error-block h3 {
    margin: 0 0 12px;
    font-size: 18px;
}

.loaded-recipes-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
}

.loaded-recipes-help {
    margin: 0 0 12px;
    color: #5e6577;
    font-size: 13px;
}

.planner-add-header-btn {
    padding: 8px 12px;
    font-size: 13px;
}

.recipe-planner-board {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.planner-item {
    width: 100%;
}

.planner-header-card {
    border: 1px solid #e3e7ef;
    border-radius: 12px;
    background: #fbfcff;
    padding: 12px;
    box-shadow: 0 2px 10px rgba(47, 51, 64, 0.06);
    cursor: grab;
    --planner-title-size: 18px;
}

.planner-header-card.dragging,
.planner-recipe-card.dragging {
    opacity: 0.5;
}

.planner-column-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0;
    border: none;
    border-radius: 0;
    background: transparent;
}

.planner-drag-handle {
    color: #6c7390;
    font-size: 16px;
    cursor: grab;
    border: none;
    border-radius: 0;
    background: transparent;
    padding: 0 4px;
    line-height: 1.1;
    touch-action: none;
}

.planner-title-input {
    flex: 1;
    border: 1px solid #dbe1ed;
    border-radius: 8px;
    padding: 6px 9px;
    font-weight: 700;
    color: #2f3340;
    min-width: 80px;
    font-family: inherit;
    background: #fff;
    font-size: var(--planner-title-size, 22px);
}

.planner-size-select {
    border: 1px solid #d4dceb;
    border-radius: 8px;
    padding: 6px 8px;
    font-size: 12px;
    color: #2f3340;
    background: #fff;
}

.planner-recipe-card {
    position: relative;
    padding-top: 36px;
    padding-left: 72px;
    cursor: grab;
}

.planner-recipe-drag-handle {
    position: absolute;
    top: 10px;
    left: 10px;
}

.planner-remove-btn {
    border: 1px solid #d6dceb;
    background: #ffffff;
    color: #566073;
    border-radius: 8px;
    width: 28px;
    height: 28px;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
}

.planner-recipe-remove-btn {
    position: absolute;
    top: 10px;
    left: 38px;
}

.loaded-recipe-url,
.ingredient-count {
    margin-top: 6px;
    color: #5e6577;
    font-size: 13px;
    word-break: break-word;
}

.loaded-recipe-url a {
    color: #5e6577;
    text-decoration: underline;
}

.recipe-ingredients-toggle {
    margin-top: 10px;
}

.recipe-ingredients-toggle summary {
    font-size: 13px;
    color: #4e5567;
    cursor: pointer;
    user-select: none;
}

.recipe-ingredients-list {
    margin: 8px 0 0;
    padding-left: 18px;
}

.recipe-ingredients-list li {
    font-size: 12px;
    color: #5e6577;
    margin: 4px 0;
}

.error-item {
    background: #fff6f7;
    border-color: #f2c7cf;
}

.error-item span {
    color: #7a3344;
    font-size: 14px;
}

.grocery-toolbar-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 10px;
}

.grocery-export-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.ourgroceries-hint {
    font-size: 13px;
    line-height: 1.45;
    color: #5e6577;
    margin: 10px 0 0;
    max-width: 42em;
}

.ourgroceries-hint a {
    color: #3d5a80;
}

.ourgroceries-hint code {
    font-size: 12px;
    background: #f0f2f7;
    padding: 2px 6px;
    border-radius: 4px;
}

.grocery-sync-btn {
    font-weight: 600;
}

.ourgroceries-sync-status {
    margin-top: 12px;
    padding: 12px 14px;
    border-radius: 10px;
    font-size: 15px;
    line-height: 1.45;
    max-width: 42em;
}

.ourgroceries-sync-status--success {
    background: #ecfdf3;
    border: 1px solid #a7f3d0;
    color: #14532d;
}

.ourgroceries-sync-status--error {
    background: #fff6f7;
    border: 1px solid #f2c7cf;
    color: #7a3344;
}

.ourgroceries-sync-status--pending {
    background: #f0f7ff;
    border: 1px solid #bfdbfe;
    color: #1e3a5f;
}

.grocery-list {
    margin-top: 8px;
}

.grocery-header-row {
    display: grid;
    grid-template-columns: 28px 1fr 34px;
    gap: 14px;
    align-items: center;
    margin: 18px 0 8px;
    padding: 6px 0;
    cursor: grab;
}

.grocery-header-input {
    border: 1px solid #d4dceb;
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 16px;
    font-weight: 700;
    color: #2f3340;
    background: #ffffff;
}

.grocery-row {
    display: grid;
    grid-template-columns: 28px 34px 34px 120px minmax(180px, 1fr);
    gap: 14px;
    align-items: center;
    margin: 8px 0;
    cursor: text;
}

.grocery-drag-col {
    display: flex;
    justify-content: center;
}

.grocery-drag-handle {
    border: none;
    background: transparent;
    color: #6b7280;
    font-size: 16px;
    line-height: 1;
    cursor: grab;
    padding: 0;
    touch-action: none;
}

.grocery-row.dragging {
    opacity: 0.5;
}

.grocery-header-row.dragging {
    opacity: 0.5;
}

.touch-dragging {
    opacity: 0.6;
}

.grocery-remove-col {
    display: flex;
    justify-content: center;
}

.grocery-remove-btn {
    border: 1px solid #d6dceb;
    background: #ffffff;
    color: #566073;
    border-radius: 8px;
    width: 28px;
    height: 28px;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
}

.checkbox-col input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
}

.quantity-col,
.item-col {
    padding: 8px 10px;
    border-radius: 10px;
    white-space: normal;
    overflow-wrap: anywhere;
}

.quantity-col {
    grid-column: 4;
    font-size: 13px;
    font-weight: 700;
    color: #2f3340;
    background: #f5f7fb;
}

.item-col {
    grid-column: 5;
    font-size: 14px;
    color: #2f3340;
    background: #f9fbff;
}

.quantity-col:focus,
.item-col:focus {
    outline: 2px solid #d4dceb;
    background: #ffffff;
}

.empty-state {
    background: #f4f6fb;
    color: #566073;
    border: 1px solid #dde3ef;
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 14px;
}

@media (max-width: 850px) {
    .main-layout {
        grid-template-columns: 1fr;
    }

    .stacked-on-mobile {
        flex-direction: column;
    }

    .planner-item {
        width: 100%;
    }

    .loaded-recipes-head {
        flex-direction: column;
        align-items: flex-start;
    }

    .planner-column-header {
        flex-wrap: wrap;
    }

    .planner-title-input {
        min-width: 0;
        width: 100%;
    }

    .grocery-header-row {
        grid-template-columns: 24px 1fr 30px;
        gap: 8px;
        margin: 12px 0 6px;
    }

    .grocery-header-input {
        font-size: 15px;
        padding: 7px 9px;
    }

    .grocery-row {
        grid-template-columns: 22px 26px 26px 14ch minmax(120px, 1fr);
        gap: 8px;
        align-items: center;
    }

    .quantity-col,
    .item-col {
        padding: 7px 8px;
    }

    .quantity-col {
        grid-column: 4;
        width: 14ch;
        min-width: 14ch;
        max-width: 14ch;
        white-space: nowrap;
        overflow-wrap: normal;
        overflow: hidden;
        text-overflow: ellipsis;
        box-sizing: border-box;
    }

    .item-col {
        grid-column: 5;
        min-width: 0;
        overflow-wrap: break-word;
    }

    .grocery-toolbar-row {
        flex-direction: column;
        align-items: stretch;
    }

    .grocery-toolbar-row > button {
        width: 100%;
    }
}
