:root {
    --manual-red: #FE4A26;
    --border-color: #000000;
    --bg-gray: #f5f5f5;
    --card-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: 'Noto Sans TC', sans-serif;
    background-color: #f5f5f5;
    color: #000000;
    display: flex;
    justify-content: center;
    padding: 20px 0;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: initial;
    /* Restore local rendering for sharpness */
    letter-spacing: 0.01em;
}

.manual-container {
    width: 90%;
    max-width: 850px;
    background: white;
    padding: 0 0 40px;
    position: relative;
    margin: 0 auto;
}

/* Page Header */
.manual-header-box {
    text-align: center;
    padding: 10px 0 10px;
}

.manual-header-box h1 {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: 5px;
    display: inline-block;
    color: #000;
    margin-top: 15px;
}

/* Tabs for switching modes */
.mode-tabs {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 5px;
}

.tab-btn {
    background: #f0f0f0;
    border: 1px solid #ccc;
    padding: 8px 20px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.3s;
    color: #555;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tab-btn.active {
    background: var(--manual-red);
    color: white;
    border-color: var(--manual-red);
    box-shadow: 0 2px 5px rgba(254, 74, 38, 0.3);
}

.tab-btn:hover:not(.active) {
    background: #e5e5e5;
}


/* Landing Overlay */
.landing-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #f5f5f5;
    background-image: radial-gradient(#d0d0d0 1px, transparent 1px);
    background-size: 20px 20px;
    z-index: 10000;
    display: block;
    /* Change from flex to block to allow natural scrolling */
    overflow-y: auto;
    /* Enable vertical scrolling */
    padding: 0;
    color: #000;
    transition: transform 0.6s cubic-bezier(0.86, 0, 0.07, 1), opacity 0.5s ease;
}

.landing-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-100%);
}

.landing-content {
    max-width: 900px;
    width: 100%;
    text-align: center;
    padding: 60px 20px;
    /* Add padding for scroll room */
    margin: 0 auto;
    animation: fadeInUp 0.8s ease-out;
}

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

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

.landing-title {
    font-size: 38px;
    font-weight: 900;
    margin-bottom: 5px;
    letter-spacing: 5px;
    color: #000;
}

.landing-subtitle {
    font-size: 16px;
    opacity: 0.8;
    margin-bottom: 50px;
    font-weight: 500;
    letter-spacing: 1px;
}

.landing-choices {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 40px;
}

.landing-card {
    background: #fff;
    border: 3px solid #000;
    border-radius: 4px;
    padding: 30px 25px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: #000;
    text-align: left;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    box-shadow: 6px 6px 0px rgba(0, 0, 0, 0.1);
}

.landing-card:hover {
    background: #fff;
    border-color: var(--manual-red);
    transform: translate(-3px, -3px);
    box-shadow: 10px 10px 0px rgba(254, 74, 38, 0.2);
}

.landing-card::before {
    display: none;
}

.card-icon {
    font-size: 50px;
    margin-bottom: 20px;
    background: #f0f0f0;
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 2px solid #000;
    transition: transform 0.3s ease, background 0.3s ease;
}

.landing-card:hover .card-icon {
    transform: scale(1.05);
    background: #fff1ef;
    border-color: var(--manual-red);
}

.card-info h3 {
    font-size: 24px;
    margin-bottom: 15px;
    font-weight: 900;
    text-align: center;
    letter-spacing: 2px;
}

.card-info p {
    font-size: 14px;
    line-height: 1.6;
    color: #444;
    margin-bottom: 30px;
    text-align: center;
    max-width: 280px;
}

.card-action {
    background: #000;
    color: white;
    padding: 12px 35px;
    border-radius: 4px;
    font-weight: 900;
    font-size: 15px;
    transition: all 0.2s;
    margin-top: auto;
    letter-spacing: 1px;
}

.landing-card:hover .card-action {
    background: var(--manual-red);
}

.landing-card:active .card-action {
    transform: scale(0.95);
}

.landing-footer {
    margin-top: 20px;
    font-size: 13px;
    font-weight: 500;
    color: #666;
    letter-spacing: 1px;
    border-top: 1px dashed #ccc;
    padding-top: 20px;
    display: inline-block;
}

@media (max-width: 600px) {
    .landing-choices {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .landing-title {
        font-size: 26px;
        letter-spacing: 2px;
    }

    .landing-card {
        padding: 20px 15px;
    }

    .card-icon {
        width: 70px;
        height: 70px;
        font-size: 35px;
        margin-bottom: 12px;
    }

    .card-info h3 {
        font-size: 20px;
        margin-bottom: 8px;
    }

    .card-info p {
        font-size: 13px;
        margin-bottom: 20px;
    }
}

/* Progress Bar (Interactive Add-on) */
.progress-section {
    position: fixed;
    top: 20px;
    left: 20px;
    width: 250px;
    background: white;
    padding: 18px;
    border: 1px solid #ddd;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    border-radius: 8px;
}

.progress-header {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 5px;
}

.progress-bar-bg {
    height: 8px;
    background: #eee;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--manual-red);
    width: 0%;
    transition: width 0.3s;
}

/* Table Layout */
.manual-table {
    border: 2.5px solid var(--border-color);
    margin: 0 15px 20px;
}

.category-row {
    display: flex;
    border-bottom: 2.5px solid var(--border-color);
}

.category-row:last-child {
    border-bottom: none;
}

.side-header {
    background-color: var(--manual-red);
    color: white;
    width: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px 0;
    writing-mode: vertical-rl;
    text-orientation: upright;
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 3px;
    flex-shrink: 0;
}

.content-area {
    flex-grow: 1;
}

.sub-category {
    display: flex;
    border-bottom: 1.5px solid var(--border-color);
    min-height: 52px;
}

.sub-category:last-child {
    border-bottom: none;
}

.sub-label {
    width: 140px;
    padding: 10px 8px;
    font-weight: 700;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-right: 2.5px solid var(--border-color);
    text-align: center;
    background: #fff;
    flex-shrink: 0;
    line-height: 1.3;
    letter-spacing: 1px;
    white-space: normal;
}

.items-container {
    padding: 16px 20px;
    flex-grow: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 25px;
    align-content: center;
}


.item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 15px;
    cursor: pointer;
    line-height: 1.5;
    margin-bottom: 4px;
}

.item.span-2 {
    grid-column: span 2;
}

.item input {
    margin-top: 2px;
    width: 15px;
    height: 15px;
    cursor: pointer;
}

.item-text {
    display: block;
    flex-grow: 1;
}

.item-label {
    font-weight: 500;
    color: #000;
    letter-spacing: 0.02em;
}

.item-desc {
    font-size: 12px;
    color: var(--manual-red);
    display: inline;
    margin-left: 6px;
    font-weight: normal;
}

/* Custom Items */
.custom-item-row {
    grid-column: span 2;
    border-top: 1px dashed #ddd;
    margin-top: 10px;
    padding-top: 10px;
}

.custom-input-group {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
}

.custom-input {
    flex-grow: 1;
    border: 1px solid #000;
    padding: 6px 12px;
    font-size: 14px;
    font-family: inherit;
    border-radius: 4px;
}

.add-item-btn {
    background: #000;
    color: white;
    border: 1px solid #000;
    padding: 6px 15px;
    font-weight: bold;
    cursor: pointer;
    border-radius: 4px;
    font-size: 13px;
    flex-shrink: 0;
    /* Prevents button from being squeezed out */
}

.add-item-btn:hover {
    background: var(--manual-red);
    border-color: var(--manual-red);
}

.delete-btn {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    font-size: 16px;
    padding: 0 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.delete-btn:hover {
    color: var(--manual-red);
    background: none;
}

.delete-btn {
    flex-shrink: 0;
    /* Prevents delete button from being squeezed out */
}

@media screen and (max-width: 768px) {
    .custom-item-row {
        grid-column: span 1;
    }
}

/* Date & Tips Section */
.manual-footer-info {
    margin: 0 15px 30px;
    padding: 15px;
    border: 1.5px solid #ccc;
    background-color: #fcfcfc;
}

.date-row {
    margin-bottom: 10px;
    font-size: 14px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 10px;
}

.update-date {
    color: var(--manual-red);
}

.tips-box {
    border-top: 1px dashed #ccc;
    padding-top: 10px;
}

.tips-box h4 {
    font-size: 13px;
    color: #333;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.tips-box ul {
    list-style: none;
    font-size: 12px;
    color: #666;
    line-height: 1.6;
}

.tips-box li::before {
    content: '•';
    color: var(--manual-red);
    margin-right: 5px;
    font-weight: bold;
}

/* Special Rows - Single Column */
.single-col .items-container {
    grid-template-columns: 1fr;
}

/* Official Link Button */
.official-link-box {
    text-align: center;
    margin: 10px 0 5px;
}

.official-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    background: transparent;
    color: var(--manual-red);
    border: 2px solid var(--manual-red);
    text-decoration: none;
    font-weight: 700;
    font-size: 14px;
    border-radius: 4px;
    transition: all 0.2s;
}

.official-btn:hover {
    background: var(--manual-red);
    color: white;
}

.official-btn::before {
    content: '🔗';
    font-size: 16px;
}

/* Creator Credit */
.creator-credit {
    text-align: center;
    margin: 10px 0 10px;
    font-size: 12px;
    color: #999;
    padding-top: 0;
}

.creator-credit a {
    color: #666;
    text-decoration: none;
    font-weight: 500;
}

.creator-credit a:hover {
    color: var(--manual-red);
    text-decoration: underline;
}

/* Actions Spacing */
.actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    /* Allow wrapping on narrow desktop/tablets if needed, but keep centered/spaced */
    flex-wrap: wrap;
}

.actions button {
    flex: 1;
    /* Distribute space evenly */
    min-width: 80px;
    /* Prevent being too narrow */
    white-space: nowrap;
    padding: 8px 5px;
    font-size: 11px;
}

#calendar-btn {
    background: #FFF9C4;
    color: #856404;
    border: 1px solid #ffee58;
}

#calendar-btn:hover {
    background: #fff176;
}

button {
    padding: 6px 15px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    border: 1px solid #000;
    background: white;
}

button:hover {
    background: #f0f0f0;
}

.primary-btn {
    background: var(--manual-red);
    color: white;
    border-color: var(--manual-red);
}

@media print {
    @page {
        size: A4;
        margin: 0.5cm;
        /* Tighter margins */
    }

    body {
        background: white;
        padding: 0;
        display: block;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .manual-container {
        width: 100%;
        max-width: none;
        border: none;
        box-shadow: none;
        transform: scale(0.9);
        /* Reduce scale to fit */
        transform-origin: top center;
        margin: 0;
        padding: 0;
    }

    .progress-section,
    .actions,
    .top-right-note,
    .official-link-box,
    .creator-credit {
        display: none !important;
    }

    .manual-header-box {
        padding: 5px 0;
        /* Reduced padding */
    }

    .manual-header-box h1 {
        font-size: 26px;
        /* Slightly smaller header */
        margin-bottom: 5px;
    }

    .manual-table {
        margin: 0;
        border-width: 2px;
    }

    .category-row {
        border-bottom-width: 2px;
        page-break-inside: avoid;
    }

    .side-header {
        font-size: 14px;
        width: 28px;
        padding: 0 4px;
    }

    .sub-category {
        min-height: 32px;
    }

    .sub-label {
        width: 100px;
        font-size: 13px;
        padding: 4px;
    }

    .items-container {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        grid-auto-flow: dense !important;
        padding: 4px 10px;
        /* Tighter padding */
        gap: 0 10px;
    }

    .item {
        font-size: 13px;
        /* Smaller font */
        line-height: 1.35;
        margin: 0;
    }

    .item-desc {
        font-size: 10.5px;
    }

    .manual-footer-info {
        margin: 5px 0 0;
        padding: 8px;
        border-width: 1.5px;
    }

    .date-row {
        font-size: 12px;
        margin-bottom: 2px;
    }

    .tips-box {
        padding-top: 4px;
    }

    .tips-box h4 {
        font-size: 12px;
        margin-bottom: 2px;
    }

    .tips-box ul {
        font-size: 11px;
        line-height: 1.3;
    }
}

@media screen and (max-width: 768px) {
    body {
        padding: 0;
        display: block;
        overflow-x: hidden;
    }

    .manual-container {
        width: 100%;
        padding: 0 0 20px;
        margin: 0;
        box-sizing: border-box;
    }

    .manual-header-box h1 {
        font-size: 24px;
        letter-spacing: 2px;
        padding: 10px 0;
    }

    .progress-section {
        position: sticky;
        top: 0;
        width: 100%;
        border: none;
        border-radius: 0;
        border-bottom: 1px solid #ddd;
        padding: 10px 12px;
        margin-bottom: 10px;
        z-index: 999;
        box-sizing: border-box;
    }

    .manual-table {
        margin: 0 10px 20px;
        width: calc(100% - 20px);
        box-sizing: border-box;
    }

    .category-row {
        flex-direction: column;
    }

    .side-header {
        width: 100%;
        padding: 12px;
        writing-mode: horizontal-tb;
        border-bottom: 2px solid var(--border-color);
        font-size: 18px;
        box-sizing: border-box;
    }

    .sub-category {
        flex-direction: column;
    }

    .sub-label {
        width: 100%;
        border-right: none;
        border-bottom: 1.5px solid var(--border-color);
        background: #fafafa;
        padding: 10px;
        font-size: 16px;
        box-sizing: border-box;
    }

    .items-container {
        display: block;
        /* Simpler than grid for mobile text heavy rows */
        padding: 10px 12px;
        box-sizing: border-box;
    }

    .item,
    .item.span-2 {
        display: flex;
        justify-content: flex-start;
        align-items: flex-start;
        box-sizing: border-box;
        width: 100%;
        margin-bottom: 12px;
        /* Spacing between items */
        gap: 10px;
    }

    .item input[type="checkbox"] {
        margin-top: 4px;
        /* Align with first line of high line-height text */
        flex-shrink: 0;
    }

    .item-text {
        flex: 1;
        min-width: 0;
        overflow-wrap: break-word;
        /* Natural wrapping */
        word-break: normal;
        padding-right: 5px;
    }

    .item-label {
        font-weight: 500;
        display: inline;
    }

    .item-desc {
        display: block;
        /* Force description to its own line for clarity on mobile */
        font-size: 12px;
        margin-left: 0;
        margin-top: 4px;
        color: var(--manual-red);
    }

    .custom-input-group {
        width: 100%;
        display: flex;
        gap: 8px;
        box-sizing: border-box;
    }

    .custom-input {
        width: 0;
        flex: 1;
        font-size: 16px;
        min-width: 0;
        box-sizing: border-box;
    }

    .add-item-btn,
    .delete-btn {
        flex-shrink: 0;
    }

    .actions {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        padding: 10px 12px;
        gap: 8px;
        -webkit-overflow-scrolling: touch;
        box-sizing: border-box;
    }

    .actions button {
        flex: 0 0 auto;
        padding: 8px 12px;
    }

    .actions::-webkit-scrollbar {
        display: none;
    }

    .manual-footer-info {
        margin: 10px;
        box-sizing: border-box;
    }
}