:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --bg: #0f172a;
    --bg-light: #1e293b;
    --bg-card: #334155;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --radius: 16px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    touch-action: manipulation;
}

.screen {
    display: none;
    min-height: 100vh;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

.screen.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.container {
    max-width: 500px;
    margin: 0 auto;
}

.header {
    text-align: center;
    margin-bottom: 32px;
    position: relative;
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--primary) 0%, #ec4899 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header h2 {
    font-size: 1.8rem;
    color: var(--text);
}

.subtitle {
    color: var(--text-muted);
    font-size: 1rem;
}

.form-section {
    margin-bottom: 24px;
}

label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
}

.input-field {
    width: 100%;
    padding: 16px;
    background: var(--bg-light);
    border: 2px solid var(--bg-card);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 1rem;
    transition: all 0.2s;
    -webkit-appearance: none;
}

.input-field:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-card);
}

select.input-field {
    cursor: pointer;
}

textarea.input-field {
    resize: vertical;
    font-family: inherit;
}

.time-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 8px;
}

.time-btn {
    padding: 16px;
    background: var(--bg-light);
    border: 2px solid var(--bg-card);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.time-btn:active {
    transform: scale(0.95);
}

.time-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.btn-primary, .btn-secondary, .btn-tertiary {
    width: 100%;
    padding: 18px;
    border: none;
    border-radius: var(--radius);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 12px;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:active {
    background: var(--primary-dark);
    transform: scale(0.98);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text);
}

.btn-secondary:active {
    background: var(--secondary);
    transform: scale(0.98);
}

.btn-tertiary {
    background: transparent;
    color: var(--text-muted);
    border: 2px solid var(--bg-card);
}

.btn-tertiary:active {
    border-color: var(--secondary);
}

.btn-success {
    width: 100%;
    padding: 16px 32px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4);
    margin-bottom: 12px;
}

.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.5);
}

.btn-success:active {
    transform: translateY(0);
}

.btn-icon {
    position: absolute;
    right: 0;
    top: 0;
    background: var(--bg-card);
    border: none;
    color: var(--text);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon:active {
    transform: scale(0.9);
}

.task-card {
    background: var(--bg-light);
    border: 2px solid var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
}

.task-category {
    display: inline-block;
    padding: 6px 12px;
    background: var(--primary);
    color: white;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 12px;
}

.task-title {
    font-size: 1.5rem;
    margin-bottom: 12px;
    line-height: 1.4;
}

.task-time {
    color: var(--text-muted);
    font-size: 1rem;
    margin-bottom: 16px;
}

.task-steps {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--bg-card);
}

.task-steps ul {
    list-style: none;
    padding-left: 0;
}

.task-steps li {
    padding: 8px 0;
    padding-left: 24px;
    position: relative;
    color: var(--text-muted);
}

.task-steps li:before {
    content: "→";
    position: absolute;
    left: 0;
    color: var(--primary);
}

.button-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Settings Dropdown */
.settings-dropdown {
    margin-top: 16px;
    width: 100%;
}

.settings-dropdown summary {
    width: 100%;
    padding: 16px 32px;
    cursor: pointer;
    list-style: none;
    text-align: center;
    transition: all 0.3s;
}

.settings-dropdown summary::-webkit-details-marker {
    display: none;
}

.settings-dropdown[open] summary {
    margin-bottom: 8px;
}

.dropdown-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px;
    background: var(--bg-light);
    border-radius: 12px;
    margin-top: 8px;
}

.btn-dropdown {
    width: 100%;
    padding: 14px 24px;
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.btn-dropdown:hover {
    background: var(--bg);
    border-color: var(--primary);
}

.btn-dropdown:active {
    transform: scale(0.98);
}

/* Timer Display */
.timer-display {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 40px 0;
}

.timer-circle {
    position: relative;
    width: 280px;
    height: 280px;
}

.timer-svg {
    transform: rotate(-90deg);
    width: 100%;
    height: 100%;
}

.timer-bg {
    fill: none;
    stroke: var(--bg-card);
    stroke-width: 12;
}

.timer-fg {
    fill: none;
    stroke: var(--primary);
    stroke-width: 12;
    stroke-linecap: round;
    stroke-dasharray: 565.48;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 1s linear;
}

.timer-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 3rem;
    font-weight: 700;
    color: var(--text);
}

#timer-task-title {
    font-size: 1.3rem;
    text-align: center;
    margin-bottom: 8px;
}

/* Stats Bar */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 24px;
    background: var(--bg-light);
    border-radius: var(--radius);
    padding: 20px;
}

.stat {
    text-align: center;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* History List */
.history-list {
    margin-bottom: 24px;
}

.history-item {
    background: var(--bg-light);
    border-left: 4px solid var(--primary);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
}

.history-item.done {
    border-left-color: var(--success);
}

.history-item.skipped {
    border-left-color: var(--danger);
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.history-item-title {
    font-weight: 600;
    font-size: 1rem;
}

.history-item-status {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}

.history-item-status.done {
    background: var(--success);
    color: white;
}

.history-item-status.skipped {
    background: var(--danger);
    color: white;
}

.history-item-meta {
    color: var(--text-muted);
    font-size: 0.85rem;
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.history-item-note {
    margin-top: 8px;
    padding: 8px;
    background: var(--bg-card);
    border-radius: 6px;
    font-size: 0.9rem;
    color: var(--text-muted);
    font-style: italic;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state-text {
    font-size: 1.1rem;
}

/* Pro/Upgrade Styles */
.upgrade-card {
    background: var(--bg-light);
    border: 2px solid var(--primary);
    border-radius: var(--radius);
    padding: 32px 24px;
    text-align: center;
}

.upgrade-icon {
    font-size: 4rem;
    margin-bottom: 16px;
}

.upgrade-card h3 {
    font-size: 1.5rem;
    margin-bottom: 24px;
}

.feature-list {
    text-align: left;
    margin: 24px 0;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--bg-card);
}

.feature-item:last-child {
    border-bottom: none;
}

.feature-icon {
    font-size: 1.2rem;
}

.pricing {
    margin: 32px 0;
    padding: 24px;
    background: var(--bg-card);
    border-radius: var(--radius);
}

.price-amount {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
}

.price-note {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.upgrade-note {
    margin-top: 24px;
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.6;
}

/* Tabs */
.manage-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
}

.tab-btn {
    flex: 1;
    padding: 12px;
    background: var(--bg-light);
    border: 2px solid var(--bg-card);
    border-radius: 12px;
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Manage Lists */
.manage-list {
    margin-top: 16px;
}

.manage-item {
    background: var(--bg-light);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.manage-item-info {
    flex: 1;
}

.manage-item-name {
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 4px;
}

.manage-item-details {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.manage-item-actions {
    display: flex;
    gap: 32px;
}

.manage-item.disabled-item {
    opacity: 0.5;
}

.manage-item.disabled-item .manage-item-name {
    text-decoration: line-through;
}

.task-section {
    margin-bottom: 24px;
}

.task-section h3 {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 12px;
    padding-left: 4px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-icon-small {
    cursor: pointer;
    user-select: none;
    padding: 8px 12px;
    margin: -12px -12px 0 -12px;
    border-radius: 12px 12px 0 0;
    background: var(--bg-card);
    transition: background 0.2s;
}

.task-section.collapsible h3:hover {
    background: var(--bg);
}

.task-section.collapsible h3::after {
    content: ' ▼';
    float: right;
    font-size: 0.8rem;
    transition: transform 0.3s;
}

.task-section.collapsible.collapsed h3::after {
    transform: rotate(-90deg);
}

.task-section.collapsible .section-content {
    max-height: 10000px;
    overflow: hidden;
    transition: max-height 0.5s ease-out;
    padding-top: 12px;
}

.task-section.collapsible.collapsed .section-content {
    max-height: 0;
    padding-top: 0;
}

.category-group {
    margin-bottom: 16px;
}

.category-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 8px;
    padding: 6px 12px;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 8px;
    border-left: 3px solid var(--primary);
}

.btn-icon-small {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: var(--bg-card);
    border: none;
    color: var(--text);
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon-small:active {
    transform: scale(0.9);
}

.btn-icon-small.delete {
    background: var(--danger);
    color: white;
}

/* Pro Badge */
.pro-badge {
    display: inline-block;
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: #000;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
    margin: 8px 0;
    box-shadow: 0 2px 8px rgba(251, 191, 36, 0.3);
}

.pro-badge.hidden {
    display: none;
}

/* Products List */
.products-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
}

.product-card {
    background: var(--bg-light);
    border: 2px solid var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.product-card:active {
    transform: scale(0.98);
}

.product-card.recommended {
    border-color: var(--primary);
    background: linear-gradient(135deg, var(--bg-light) 0%, rgba(99, 102, 241, 0.1) 100%);
}

.product-recommended-badge {
    position: absolute;
    top: -10px;
    right: 16px;
    background: var(--primary);
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

.product-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.product-description {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 12px;
}

.product-pricing {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--bg-card);
}

.product-price {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary);
}

.product-period {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.product-discount {
    background: var(--success);
    color: white;
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
}

.purchase-note,
.subscription-note {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    line-height: 1.8;
    margin-top: 24px;
}

/* Subscription Management */
.subscription-card {
    background: var(--bg-light);
    border: 2px solid var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
}

.sub-status {
    text-align: center;
    margin-bottom: 24px;
}

.status-badge {
    display: inline-block;
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 1rem;
}

.status-badge.active {
    background: var(--success);
    color: white;
}

.status-badge.cancelled {
    background: var(--danger);
    color: white;
}

.status-badge.expired {
    background: var(--secondary);
    color: white;
}

.sub-details {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sub-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--bg-card);
}

.sub-row:last-child {
    border-bottom: none;
}

.sub-label {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.sub-value {
    font-weight: 600;
    text-align: right;
}

/* Loading Spinner */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--bg-card);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 400px) {
    .header h1 {
        font-size: 2rem;
    }
    
    .timer-circle {
        width: 240px;
        height: 240px;
    }
    
    .timer-text {
        font-size: 2.5rem;
    }
}

/* PWA Specific */
@media (display-mode: standalone) {
    .screen {
        padding-top: calc(20px + env(safe-area-inset-top));
        padding-bottom: calc(20px + env(safe-area-inset-bottom));
    }
}
