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

html {
    overflow-y: scroll;
}

:root {
    --primary-color: #6366f1;
    --secondary-color: #8b5cf6;
    --error-color: #ef4444;
    --success-color: #10b981;
    --light-bg: #f9fafb;
    --white: #ffffff;
    --text-dark: #111827;
    --text-light: #6b7280;
    --border-color: #e5e7eb;
    --shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
        'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
        sans-serif;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    min-height: 100vh;
    color: var(--text-dark);
}

/* --- Landing page --- */
header {
    display: flex;
    justify-content: flex-end;
    padding: 24px 40px;
    gap: 12px;
}

.btn {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: var(--white);
    border: none;
    padding: 12px 28px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(99, 102, 241, 0.4);
}

.btn:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--light-bg);
    color: var(--text-dark);
    border: 2px solid var(--border-color);
    font-size: 13px;
    padding: 10px 18px;
    white-space: nowrap;
}

.btn-secondary:hover {
    background: var(--border-color);
    transform: none;
    box-shadow: none;
}

.btn-wide {
    width: 100%;
    text-align: center;
}

main {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0 24px;
    min-height: calc(100vh - 80px);
}

h1 {
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--white);
}

main p {
    font-size: clamp(1rem, 2.5vw, 1.35rem);
    color: rgba(255, 255, 255, 0.9);
    max-width: 480px;
}

/* --- Signup page --- */
.signup-form {
    width: 100%;
    max-width: 520px;
    text-align: left;
    margin-top: 32px;
    background: var(--white);
    border-radius: 12px;
    padding: 40px;
    box-shadow: var(--shadow);
}

.signup-form label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-dark);
    margin-bottom: 6px;
    margin-top: 20px;
}

.signup-form label:first-child {
    margin-top: 0;
}

.signup-form input {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    background: var(--white);
    color: var(--text-dark);
    outline: none;
    transition: border-color 0.3s;
}

.signup-form input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.signup-form input::placeholder {
    color: var(--text-light);
}

.token-row {
    display: flex;
    gap: 10px;
    margin-top: 6px;
}

.token-row input {
    flex: 1;
}

.signup-form select {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    background: var(--white);
    color: var(--text-dark);
    outline: none;
    cursor: pointer;
    transition: border-color 0.3s;
}

.signup-form select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-top: 28px;
    gap: 16px;
}

#error-msg {
    color: var(--error-color);
    font-size: 14px;
    text-align: right;
}

/* --- Success message --- */
.success-box {
    text-align: center;
    padding: 48px 24px;
}

.success-icon {
    width: 72px;
    height: 72px;
    background: linear-gradient(135deg, var(--success-color), #059669);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    font-weight: 700;
    color: var(--white);
    margin: 0 auto 24px;
}

.success-box h2 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-dark);
}

.success-box p {
    font-size: 1.1rem;
    color: var(--text-light);
    max-width: 360px;
    margin: 0 auto;
}
.success-box .btn {
  margin-top: 24px;
}

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease-in;
}

.modal-overlay.hidden {
    display: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal {
    background: var(--white);
    border-radius: 12px;
    padding: 32px;
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 420px;
}

.modal-scroll {
    max-height: 80vh;
    overflow-y: auto;
}

.modal h2 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 24px;
    color: var(--text-dark);
    text-align: center;
}

.modal label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-dark);
    margin-bottom: 6px;
    margin-top: 16px;
}

.modal label:first-of-type {
    margin-top: 0;
}

.modal input {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    background: var(--white);
    color: var(--text-dark);
    outline: none;
    transition: border-color 0.3s;
}

.modal input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.modal input::placeholder {
    color: var(--text-light);
}

.modal-error {
    display: block;
    color: var(--error-color);
    font-size: 13px;
    margin-top: 12px;
    text-align: center;
    min-height: 20px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
}

.modal-actions-center {
    justify-content: center;
}

.modal-success {
    text-align: center;
}

.modal-success .success-icon {
    width: 72px;
    height: 72px;
    background: linear-gradient(135deg, var(--success-color), #059669);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    font-weight: 700;
    color: var(--white);
    margin: 0 auto 20px;
}

.modal-success h2 {
    margin-bottom: 0;
    color: var(--text-dark);
}

/* --- Settings --- */
.settings-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 12px;
    padding: 24px 0;
}

/* --- Tasks page --- */
.tasks-page {
    justify-content: flex-start;
    align-items: center;
}

.tasks-header {
    position: sticky;
    top: 0;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    z-index: 10;
    padding-top: 16px;
    width: 100%;
    max-width: 600px;
}

.tasks-header h1 {
    margin-bottom: 0;
}

.tasks-container {
    width: 100%;
    max-width: 600px;
    margin-top: 16px;
    padding-bottom: 80px;
}

.task-card {
    background: var(--white);
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 12px;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    border-left: 4px solid var(--primary-color);
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.task-card:hover {
    transform: translateX(4px);
    transition: all 0.2s;
}

.task-content {
    flex: 1;
    min-width: 0;
}

.task-text {
    font-size: 15px;
    color: var(--text-dark);
    word-wrap: break-word;
    line-height: 1.5;
}

.task-notes {
    font-size: 13px;
    color: var(--text-light);
    margin-top: 4px;
    word-wrap: break-word;
    line-height: 1.4;
}

.task-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.task-btn {
    background: none;
    border: none;
    border-radius: 6px;
    color: var(--text-light);
    font-size: 16px;
    padding: 6px 8px;
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1;
}

.task-btn:hover {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-color);
}

.task-btn-delete:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error-color);
}

.task-btn-edit:hover {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-color);
}

.edit-select {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    background: var(--white);
    color: var(--text-dark);
    outline: none;
    cursor: pointer;
    transition: border-color 0.3s;
}

.edit-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.empty-text, .error-text {
    color: var(--text-light);
    font-size: 16px;
    margin-top: 24px;
    text-align: center;
    padding: 40px 20px;
    background: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.error-text {
    color: var(--error-color);
    border-left: 4px solid var(--error-color);
}

/* --- Tabs --- */
.tab-bar {
    display: flex;
    align-items: center;
    width: 100%;
    margin-top: 16px;
    gap: 4px;
}

.tabs-inner {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scroll-behavior: smooth;
    -ms-overflow-style: none;
    scrollbar-width: none;
    flex: 1;
}

.tabs-inner::-webkit-scrollbar {
    display: none;
}

.tab {
    padding: 8px 16px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    backdrop-filter: blur(4px);
}

.tab:hover {
    border-color: var(--white);
    background: rgba(255, 255, 255, 0.25);
    color: var(--white);
}

.tab.active {
    background: var(--white);
    border-color: var(--white);
    color: var(--primary-color);
    font-weight: 600;
}

.tab-scroll {
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 6px;
    color: var(--white);
    font-size: 20px;
    padding: 6px 10px;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
    display: none;
    backdrop-filter: blur(4px);
}

.tab-scroll:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: var(--white);
}

.tab-scroll.visible {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- Footer --- */
.tasks-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--white);
    border-top: 2px solid var(--border-color);
    z-index: 20;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.06);
}

.footer-btn {
    background: var(--light-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-dark);
    font-size: 13px;
    font-weight: 600;
    padding: 8px 14px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.footer-btn:hover {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-color: transparent;
    color: var(--white);
    transform: translateY(-1px);
}

.footer-btn-danger:hover {
    background: var(--error-color);
    border-color: var(--error-color);
    color: var(--white);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

/* --- Category row --- */
.category-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.cat-name-input {
    flex: 2;
    padding: 10px 12px;
    font-size: 14px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--white);
    color: var(--text-dark);
    outline: none;
    transition: border-color 0.3s;
}

.cat-key-input {
    flex: 1;
    padding: 10px 12px;
    font-size: 14px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--white);
    color: var(--text-dark);
    outline: none;
    transition: border-color 0.3s;
}

.cat-name-input:focus,
.cat-key-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* --- Responsive --- */
@media (max-width: 600px) {
    header {
        padding: 16px 20px;
    }

    .signup-form {
        padding: 24px 20px;
    }

    .modal {
        margin: 16px;
        padding: 24px;
    }

    .task-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .task-actions {
        align-self: flex-end;
    }

    .tasks-footer {
        gap: 4px;
        padding: 10px 8px;
    }

    .footer-btn {
        font-size: 11px;
        padding: 6px 10px;
    }
}
