:root {
    --bg-main: #0F172A;
    --bg-card: #1E293B;
    --bg-soft: rgba(255,255,255,0.03);
    --text-main: #F8FAFC;
    --text-secondary: #94A3B8;
    --primary: #3B82F6;
    --primary-hover: #2563EB;
    --work: #60A5FA;
    --break: #34D399;
    --long-break: #A78BFA;
    --danger: #EF4444;
    --border: #334155;
    --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
}

html,
body {
    height: 100%;
}

body {
    font-family: var(--font-main);
    background: radial-gradient(circle at top, rgba(59, 130, 246, 0.08), transparent 32%), var(--bg-main);
    color: var(--text-main);
    overflow: auto;
}

.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    height: 56px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    background: #1E293B;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.14);
    flex-shrink: 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 24px;
    font-weight: 600;
}

.logo-icon {
    width: 32px;
    height: 32px;
    display: block;
    flex-shrink: 0;
}

.header-links {
    display: flex;
    align-items: center;
    gap: 18px;
}

.header-links a,
.header-links button {
    color: var(--text-secondary);
    text-decoration: none;
    background: transparent;
    border: none;
    font-size: 14px;
    cursor: pointer;
    transition: color 0.2s ease;
}

.header-links a:hover,
.header-links button:hover {
    color: var(--text-main);
}

main {
    flex: 1;
    display: flex;
    align-items: stretch;
    justify-content: flex-start;
    padding: 84px 28px 28px;
    overflow: auto;
}

.layout {
    width: min(1180px, 100%);
    display: grid;
    grid-template-columns: 360px minmax(0, 1fr);
    gap: 22px;
    align-items: stretch;
    margin: 0 auto;
}

.panel {
    background: rgba(30, 41, 59, 0.88);
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: 0 10px 28px rgba(2, 6, 23, 0.20);
}

.sidebar {
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.intro h1 {
    font-size: 28px;
    line-height: 1.2;
    margin-bottom: 8px;
}

.intro p {
    color: var(--text-secondary);
    line-height: 1.6;
    font-size: 14px;
}

.preset-group,
.settings-group,
.status-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.group-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.04em;
}

.preset-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.preset-btn {
    min-width: 96px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg-soft);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.16s ease, border-color 0.16s ease, background-color 0.16s ease, box-shadow 0.16s ease;
}

.preset-btn.active {
    color: var(--text-main);
    background: rgba(59, 130, 246, 0.16);
    border-color: rgba(59, 130, 246, 0.45);
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.12);
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.setting-card {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 10px 12px;
}

.setting-card label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-secondary);
    font-size: 12px;
}

.setting-card input {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-main);
    font-size: 24px;
    font-weight: 700;
    font-family: var(--font-mono);
    appearance: textfield;
    line-height: 1.1;
}

.setting-card input::-webkit-outer-spin-button,
.setting-card input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.toggle-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 16px;
}

.toggle-copy {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.toggle-copy strong {
    font-size: 13px;
    font-weight: normal;
    color: var(--text-secondary);
}

.toggle-copy span {
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.5;
}

.switch {
    position: relative;
    width: 52px;
    height: 30px;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.switch-slider {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.25);
    border: 1px solid rgba(148, 163, 184, 0.18);
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.switch-slider::before {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #F8FAFC;
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.24);
    transition: transform 0.2s ease;
}

.switch input:checked + .switch-slider {
    background: rgba(59, 130, 246, 0.35);
    border-color: rgba(59, 130, 246, 0.45);
}

.switch input:checked + .switch-slider::before {
    transform: translateX(22px);
}

.status-card {
    padding: 14px 16px;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.status-line {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 14px;
}

.status-line span:first-child {
    color: var(--text-secondary);
}

.note {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.6;
}

.ad-slot {
    position: relative;
}

.ad-slot-inner {
    position: relative;
    z-index: 1;
    padding: 0;
}

.ad-slot-box {
    min-height: 0;
    display: block;
    padding: 0;
    overflow: hidden;
}

.workspace-ad {
    width: min(640px, 100%);
    margin-top: 12px;
}

.workspace-ad .ad-slot-box {
    min-height: 100px;
}

.ad-svg {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 12px;
}

.ad-svg-inline {
    max-width: 640px;
}

.history-group {
    margin-top: 12px;
}

.workspace-history {
    width: min(640px, 100%);
    margin-top: 12px;
}

.workspace-history .history-panel {
    background: transparent;
    border: none;
    box-shadow: none;
}

.workspace-history .history-panel summary {
    padding: 12px 16px;
}

.workspace-history .history-content {
    padding-top: 2px;
    min-height: 0;
}

.history-panel {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
}

.history-panel summary {
    list-style: none;
    cursor: pointer;
    padding: 14px 16px;
    color: var(--text-main);
    font-size: 14px;
    font-weight: 600;
}

.history-panel summary::-webkit-details-marker {
    display: none;
}

.history-content {
    padding: 0 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
}

.history-summary-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-summary {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.6;
    padding: 10px 12px;
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.04);
    border-radius: 12px;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 0;
    overflow: visible;
}

@media (min-width: 769px) {
    .workspace-history .history-panel summary {
        padding: 14px 18px;
        font-size: 15px;
    }

    .workspace-history .history-content {
        padding: 2px 18px 18px;
        gap: 14px;
    }

    .history-summary-group {
        gap: 10px;
    }

    .history-summary {
        color: #AABACD;
        font-size: 14px;
        line-height: 1.65;
        padding: 11px 14px;
        background: rgba(148, 163, 184, 0.05);
        border-color: rgba(148, 163, 184, 0.10);
    }

    .history-list {
        padding-right: 0;
        gap: 8px;
    }

    .history-day {
        border-color: rgba(148, 163, 184, 0.10);
        background: rgba(255,255,255,0.028);
    }

    .history-day + .history-day {
        margin-top: 8px;
    }

    .history-day-summary {
        padding: 10px 14px;
        gap: 14px;
    }

    .history-day-title {
        font-size: 14px;
        color: #9FB0C3;
    }

    .history-day-subtitle {
        color: #9FB0C3;
        font-size: 12px;
    }

    .workspace-history .history-day-summary .history-day-meta {
        color: #9FB0C3;
        font-size: 13px;
        line-height: 1.45;
    }

    .history-day-list {
        gap: 6px;
        padding: 0 12px 12px;
        max-height: 300px;
    }

    .history-item {
        padding: 6px 0;
        border-bottom-color: rgba(148, 163, 184, 0.18);
    }

    .workspace-history .history-day-list .history-item-text {
        color: #AABACD;
        font-size: 14px;
        line-height: 1.55;
    }

    .history-delete {
        width: 26px;
        height: 26px;
        font-size: 14px;
        color: #90A4BA;
        border-color: rgba(148, 163, 184, 0.18);
    }
}

.history-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: center;
    padding: 4px 0;
    background: transparent;
    border: none;
    border-radius: 0;
    border-bottom: 1px dashed rgba(148, 163, 184, 0.22);
}

.history-day-list .history-item:last-child {
    border-bottom: none;
}

.history-item-text {
    color: var(--text-main);
    font-size: 11px;
    line-height: 1.35;
    word-break: break-word;
}

.history-delete {
    width: 24px;
    height: 24px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.history-delete:hover {
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.5);
    background: rgba(239, 68, 68, 0.08);
}

.history-empty {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.6;
}

.history-day {
    border: 1px solid rgba(255,255,255,0.04);
    border-radius: 14px;
    background: rgba(255,255,255,0.02);
    overflow: hidden;
}

.history-day + .history-day {
    margin-top: 6px;
}

.history-day-summary {
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    cursor: pointer;
    color: var(--text-main);
    font-size: 11px;
    user-select: none;
    transition: background 0.2s ease;
}

.history-day-summary:hover {
    background: rgba(255,255,255,0.02);
}

.history-day-summary::-webkit-details-marker {
    display: none;
}

.history-day-summary::after {
    content: '›';
    flex-shrink: 0;
    color: var(--text-secondary);
    font-size: 16px;
    line-height: 1;
    transition: transform 0.2s ease;
}

.history-day[open] .history-day-summary::after {
    transform: rotate(90deg);
}

.history-day-heading {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.history-day-title {
    font-weight: normal;
    color: var(--text-secondary);
}

.history-day-subtitle {
    color: var(--text-secondary);
    font-size: 11px;
    white-space: nowrap;
}

.history-day-meta {
    color: var(--text-secondary);
    font-size: 10px;
    text-align: right;
    line-height: 1.3;
}

.history-day-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0 8px 8px;
    max-height: 200px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.4) transparent;
}

.history-day-list::-webkit-scrollbar {
    width: 6px;
}

.history-day-list::-webkit-scrollbar-track {
    background: transparent;
}

.history-day-list::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.4);
    border-radius: 6px;
}

.history-day-list::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.6);
}

.history-panel-header {
    padding: 14px 16px;
    color: var(--text-main);
    font-size: 14px;
    font-weight: 600;
}

.workspace {
    padding: 56px 22px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    position: relative;
    overflow: visible;
    min-height: 0;
}

.display-wrap {
    position: relative;
    width: 410px;
    height: 410px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
}

.progress-ring {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.progress-ring circle {
    fill: transparent;
    stroke-width: 8;
    stroke-linecap: round;
}

.progress-ring-bg {
    stroke: var(--border);
}

.progress-ring-bar {
    stroke: var(--work);
    transform: rotate(-90deg);
    transform-origin: 50% 50%;
    transition: stroke 0.3s ease;
}

.progress-ring-bar.is-running {
    transition: stroke 0.3s ease, stroke-dashoffset 1s linear;
}

.display-center {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
}

.task-input {
    position: absolute;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
    width: 248px;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.04);
    color: var(--text-main);
    text-align: center;
    font-size: 14px;
    outline: none;
    transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.task-input::placeholder {
    color: var(--text-secondary);
}

.task-input:focus {
    border-color: rgba(59, 130, 246, 0.45);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.10);
}

.task-input:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.phase-label {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.phase-label.phase-work {
    color: var(--work);
}

.phase-label.phase-break {
    color: var(--break);
}

.phase-label.phase-long-break {
    color: var(--long-break);
}

.time-display {
    font-family: var(--font-mono);
    font-size: 86px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 2px;
    font-variant-numeric: tabular-nums;
    color: var(--text-main);
}

.meta-text {
    color: var(--text-secondary);
    font-size: 14px;
}

.controls {
    display: flex;
    gap: 16px;
    margin-bottom: 18px;
    flex-wrap: wrap;
    justify-content: center;
}

.btn-primary,
.btn-secondary {
    min-width: 124px;
    padding: 13px 24px;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.16s ease, border-color 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.btn-primary {
    border: none;
    color: #fff;
    background: linear-gradient(180deg, #4D93FF 0%, var(--primary) 100%);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.16);
}

.btn-secondary {
    border: 1px solid var(--border);
    color: var(--text-main);
    background: transparent;
}

.btn-secondary:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    color: var(--text-secondary);
    background: transparent;
}

.btn-secondary:disabled:hover {
    background: transparent;
}

.interrupt-group {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.interrupt-count {
    color: var(--text-secondary);
    font-size: 13px;
    white-space: nowrap;
}

.sub-note {
    color: var(--text-secondary);
    font-size: 13px;
    text-align: center;
    max-width: 640px;
    line-height: 1.5;
}

.toast {
    position: fixed;
    top: 72px;
    right: 20px;
    z-index: 50;
    max-width: min(360px, calc(100vw - 32px));
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    background: rgba(15, 23, 42, 0.92);
    color: var(--text-main);
    box-shadow: 0 6px 14px rgba(2, 6, 23, 0.16);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.16s ease;
}

.toast.is-visible {
    opacity: 1;
}

.toast-title {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
}

.toast-body {
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-secondary);
}

.fullscreen-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.02);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 16px;
    transition: color 0.16s ease, background-color 0.16s ease, border-color 0.16s ease;
}

.exit-fullscreen-btn {
    position: fixed;
    top: 18px;
    right: 18px;
    z-index: 90;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    background: rgba(15, 23, 42, 0.72);
    color: rgba(226, 232, 240, 0.92);
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 6px 14px rgba(2, 6, 23, 0.14);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.16s ease, background 0.2s ease;
}

.exit-fullscreen-btn.is-visible {
    opacity: 1;
    pointer-events: auto;
}

.article-content {
    max-width: 900px;
    width: calc(100% - 48px);
    margin: 48px auto 0;
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    line-height: 1.8;
    color: #64748B;
    box-shadow: none;
}

.article-content h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 32px 0 12px;
    color: #9FB0C3;
}

.article-content h2:first-child {
    margin-top: 0;
}

.article-content h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 24px 0 8px;
    color: #9FB0C3;
}

.article-content p {
    font-size: 0.875rem;
    color: #64748B;
    margin: 0 0 12px;
}

.article-content ul {
    padding-left: 20px;
    margin: 0 0 12px;
}

.article-content li {
    font-size: 0.875rem;
    color: #64748B;
    margin-bottom: 8px;
    line-height: 1.7;
}

.article-content li strong {
    color: #9FB0C3;
}

.faq-section {
    max-width: 900px;
    width: calc(100% - 48px);
    margin: 40px auto 24px;
    background: transparent;
    border: none;
    border-top: 1px dashed rgba(51, 65, 85, 0.4);
    border-radius: 0;
    padding: 32px 0 0;
    box-shadow: none;
}

.faq-section h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0 0 20px;
    color: #9FB0C3;
}

.faq-item {
    margin-bottom: 24px;
    padding-bottom: 0;
    border-bottom: none;
}

.faq-item:last-child {
    margin-bottom: 0;
}

.faq-item h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin: 0 0 6px;
    color: #9FB0C3;
}

.faq-item p {
    font-size: 0.875rem;
    color: #64748B;
    margin: 0;
    line-height: 1.7;
}

footer {
    flex-shrink: 0;
    text-align: center;
    padding: 12px;
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.7;
}

footer a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s ease;
}

footer a:hover {
    color: var(--text-main);
}

@media (max-width: 768px) {
            .sidebar {
                padding: 32px 24px !important;
            }
            .intro {
                display: none;
            }
            .status-group {
                display: none;
            }
    .article-content {
        width: calc(100% - 32px);
        padding: 0;
    }
    
    .faq-section {
        width: calc(100% - 32px);
        padding: 24px 0 0;
    }
}

.back-to-top {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 44px;
    height: 44px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 14px;
    background: rgba(15, 23, 42, 0.92);
    color: var(--text-main);
    box-shadow: 0 6px 14px rgba(2, 6, 23, 0.14);
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.16s ease, background 0.2s ease;
    z-index: 40;
}

.back-to-top.is-visible {
    opacity: 1;
    pointer-events: auto;
}

@media (hover: hover) and (pointer: fine) {
    .preset-btn:hover {
        color: var(--text-main);
        border-color: var(--text-secondary);
    }

    .btn-primary:hover {
        background: linear-gradient(180deg, #60A5FA 0%, var(--primary-hover) 100%);
    }

    .btn-secondary:hover {
        background: rgba(255,255,255,0.05);
    }

    .fullscreen-btn:hover {
        color: var(--text-main);
        background: rgba(255,255,255,0.05);
    }

    .exit-fullscreen-btn:hover {
        background: rgba(15, 23, 42, 0.86);
        color: #F8FAFC;
    }

    .back-to-top:hover {
        background: rgba(30, 41, 59, 0.96);
    }
}

@keyframes pulse-message {
    0% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    50% { transform: translate(-50%, -50%) scale(1.04); opacity: 0.82; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.finished-message {
    position: absolute;
    top: 76%;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    color: var(--danger);
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    z-index: 3;
    background: rgba(239, 68, 68, 0.12);
    padding: 4px 12px;
    border-radius: 99px;
    letter-spacing: 0.05em;
}

.display-wrap.is-alert {
    border-radius: 50%;
    box-shadow: inset 0 0 0 1px rgba(239, 68, 68, 0.12);
}

.display-wrap.is-alert .progress-ring-bar {
    stroke: var(--danger);
}

.display-wrap.is-alert .progress-ring-bg {
    stroke: rgba(239, 68, 68, 0.2);
}

.display-wrap.is-alert .time-display,
.display-wrap.is-alert .phase-label {
    color: var(--danger);
}

@media (max-width: 1080px) {
    body {
        overflow: auto;
    }

    .app {
        min-height: auto;
    }

    main {
        align-items: stretch;
        padding: 74px 18px 18px;
    }

    .layout {
        grid-template-columns: 1fr;
    }

    .workspace {
        min-height: auto;
        padding: 40px 18px 18px;
    }

    .display-wrap {
        width: 344px;
        height: 344px;
    }

    .task-input {
        top: 62px;
        width: 228px;
    }

    .time-display {
        font-size: 72px;
    }

}

@media (min-width: 500px) and (max-width: 1080px) {
    .settings-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .setting-card {
        padding: 10px;
    }

    .setting-card input {
        font-size: 20px;
    }
}

.mobile-tab-bar {
    display: none;
}

.mobile-workspace-status {
    display: none;
}

@media (max-width: 640px) {
    #notificationToggle {
        display: none !important;
    }

    body, html {
        height: 100%;
        overflow: hidden;
        overscroll-behavior-y: none;
    }

    .app {
        height: 100%;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    header {
        position: relative;
        padding: 0 14px;
        box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08);
    }

    .logo {
        font-size: 24px;
        gap: 10px;
    }

    .logo-icon {
        width: 36px;
        height: 36px;
    }

    .header-links a {
        display: none;
    }

    main {
        flex: 1;
        padding: 0;
        overflow: hidden;
        position: relative;
    }

    .layout {
        height: 100%;
        gap: 0;
        display: block;
        position: relative;
    }

    .panel {
        border-radius: 0;
        position: absolute;
        inset: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        opacity: 0;
        pointer-events: none;
        transform: none;
        transition: opacity 0.16s ease;
        background: var(--bg-main);
        border: none;
        box-shadow: none;
        padding: 0 12px 80px;
    }

    .panel.is-active {
        opacity: 1;
        pointer-events: auto;
        transform: translateX(0);
        z-index: 10;
    }

    .sidebar {
        padding-top: 12px;
    }

    .workspace {
        padding-top: 24px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;
    }

    .workspace.show-history {
        padding-top: 12px;
    }

    .workspace:not(.show-history) .workspace-history {
        display: none;
    }

    .workspace.show-history .display-wrap,
    .workspace.show-history .controls,
    .workspace.show-history .exit-fullscreen-btn {
        display: none;
    }

    .workspace.show-history .workspace-history {
        display: block;
        width: 100%;
        margin-top: 0;
    }

    .mobile-tab-bar {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: calc(64px + env(safe-area-inset-bottom));
        padding-bottom: env(safe-area-inset-bottom);
        background: rgba(15, 23, 42, 0.98);
        border-top: 1px solid rgba(255,255,255,0.06);
        box-shadow: 0 -1px 4px rgba(2, 6, 23, 0.08);
        z-index: 50;
        justify-content: space-around;
        align-items: center;
    }

    .tab-btn {
        flex: 1;
        height: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        background: transparent;
        border: none;
        color: #64748B;
        cursor: pointer;
        transition: color 0.2s ease;
    }

    .tab-btn.active {
        color: var(--primary);
    }

    .tab-icon {
        font-size: 20px;
        line-height: 1;
    }

    .tab-text {
        font-size: 11px;
        font-weight: 500;
    }

    .settings-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .mobile-workspace-status {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        position: absolute;
        top: -24px;
        left: 0;
        right: 0;
        color: var(--text-secondary);
        font-size: 13px;
    }

    .mobile-workspace-status .status-dot {
        opacity: 0.5;
    }

    .display-wrap {
        width: 280px;
        height: 280px;
        margin-top: 24px;
    }

    .display-center {
        gap: 10px;
        margin-top: 10px;
    }

    .task-input {
        top: 48px;
        width: min(180px, calc(100% - 64px));
        padding: 8px 10px;
        font-size: 16px;
    }

    .time-display {
        font-size: 56px;
    }

    .btn-primary,
    .btn-secondary {
        min-width: 104px;
        padding: 12px 18px;
        font-size: 15px;
    }

    .btn-primary {
        box-shadow: 0 2px 8px rgba(59, 130, 246, 0.14);
    }

    .toast {
        top: 64px;
        right: 12px;
        left: 12px;
        max-width: none;
        box-shadow: 0 4px 12px rgba(2, 6, 23, 0.12);
        backdrop-filter: none;
        transform: none;
        transition: none;
    }

    .back-to-top {
        display: none;
    }

    .exit-fullscreen-btn {
        top: 12px;
        right: 12px;
        padding: 9px 12px;
        font-size: 12px;
        box-shadow: 0 4px 12px rgba(2, 6, 23, 0.10);
        backdrop-filter: none;
        transform: none;
        transition: opacity 0.12s ease, background 0.2s ease;
    }

    .ad-slot-inner {
        padding: 0;
    }

    .workspace-ad .ad-slot-box {
        min-height: 84px;
    }

    .workspace-history {
        width: 100%;
        margin-top: 10px;
    }

    .workspace-history .history-panel summary {
        padding: 10px 14px;
    }

    .workspace-history .history-content {
        padding: 0 12px 12px;
    }

    .history-summary-group {
        gap: 6px;
    }

    .history-summary {
        padding: 8px 10px;
        color: #AEBED0;
        font-size: 14px;
        line-height: 1.5;
    }

    .history-day-summary {
        position: relative;
        align-items: flex-start;
        flex-direction: column;
        gap: 4px;
        padding: 8px 28px 8px 10px;
    }

    .history-day-summary::after {
        position: absolute;
        top: 9px;
        right: 10px;
    }

    .history-day-heading {
        flex-wrap: wrap;
        gap: 4px;
    }

    .history-day-title,
    .history-day-subtitle {
        font-size: 13px;
    }

    .history-day-title,
    .history-day-subtitle {
        color: #9FB0C3;
    }

    .history-day-subtitle {
        white-space: normal;
    }

    .history-day-meta {
        width: 100%;
        text-align: left;
        color: #9FB0C3;
        font-size: 12px;
        line-height: 1.4;
    }

    .history-day-list {
        gap: 2px;
        padding: 0 8px 8px;
    }

    .history-item {
        grid-template-columns: minmax(0, 1fr) 24px;
        gap: 6px;
        padding: 5px 0;
    }

    .history-item-text {
        color: #D1DBE7;
        font-size: 13px;
        line-height: 1.5;
    }

    .fullscreen-btn {
        display: none;
    }

    .article-content,
    .faq-section,
    footer {
        display: none;
    }

    .display-wrap.is-alert {
        box-shadow: none;
    }
}

.pseudo-fullscreen {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    z-index: 99999;
    overflow: hidden;
    background: var(--bg-main);
}

:fullscreen,
.pseudo-fullscreen {
    background: var(--bg-main);
}

:fullscreen .workspace,
.pseudo-fullscreen .workspace {
    background: var(--bg-main);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
}

:fullscreen .workspace-history,
.pseudo-fullscreen .workspace-history {
    display: none;
}

:fullscreen header,
.pseudo-fullscreen header,
:fullscreen footer,
.pseudo-fullscreen footer,
:fullscreen .sidebar,
.pseudo-fullscreen .sidebar,
:fullscreen .sub-note,
.pseudo-fullscreen .sub-note,
:fullscreen .workspace-history,
.pseudo-fullscreen .workspace-history,
:fullscreen .workspace-ad,
.pseudo-fullscreen .workspace-ad,
:fullscreen .header-links,
.pseudo-fullscreen .header-links,
:fullscreen .fullscreen-btn,
.pseudo-fullscreen .fullscreen-btn,
:fullscreen .back-to-top,
.pseudo-fullscreen .back-to-top,
:fullscreen .article-content,
.pseudo-fullscreen .article-content,
:fullscreen .faq-section,
.pseudo-fullscreen .faq-section {
    display: none !important;
}

:fullscreen main,
.pseudo-fullscreen main {
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-main);
}

:fullscreen .layout,
.pseudo-fullscreen .layout {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

:fullscreen .workspace,
.pseudo-fullscreen .workspace {
    width: 100%;
    min-height: 100vh;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
}

:fullscreen .display-wrap,
.pseudo-fullscreen .display-wrap {
    width: min(78vmin, calc(100vw - 80px), calc(100vh - 80px));
    height: min(78vmin, calc(100vw - 80px), calc(100vh - 80px));
}

:fullscreen .display-wrap::before,
.pseudo-fullscreen .display-wrap::before {
    display: none;
}

:fullscreen .task-input,
.pseudo-fullscreen .task-input {
    top: 16%;
    width: min(42%, 360px);
    padding: 14px 18px;
    font-size: clamp(16px, 1.8vmin, 22px);
}

:fullscreen .time-display,
.pseudo-fullscreen .time-display {
    font-size: clamp(108px, 16.5vmin, 216px);
}

:fullscreen .phase-label,
.pseudo-fullscreen .phase-label {
    font-size: clamp(20px, 3.4vmin, 38px);
}

:fullscreen .meta-text,
.pseudo-fullscreen .meta-text {
    font-size: clamp(18px, 2.8vmin, 32px);
}

@media (max-width: 640px) {
    :fullscreen .workspace,
    .pseudo-fullscreen .workspace {
        min-height: 100vh;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 14px;
        padding: max(12px, env(safe-area-inset-top)) 12px max(16px, env(safe-area-inset-bottom));
    }

    :fullscreen .display-wrap,
    .pseudo-fullscreen .display-wrap {
        width: min(calc(100vw - 24px), calc(100vh - 170px), 360px);
        height: min(calc(100vw - 24px), calc(100vh - 170px), 360px);
    }

    :fullscreen main,
    .pseudo-fullscreen main {
        background: var(--bg-main);
    }

    :fullscreen .display-wrap::before,
    .pseudo-fullscreen .display-wrap::before {
        display: none;
    }

    :fullscreen .display-center,
    .pseudo-fullscreen .display-center {
        gap: 8px;
        margin-top: 14px;
    }

    :fullscreen .task-input,
    .pseudo-fullscreen .task-input {
        top: 18%;
        width: min(calc(100% - 52px), 220px);
        padding: 10px 14px;
        font-size: clamp(14px, 3.8vw, 17px);
    }

    :fullscreen .time-display,
    .pseudo-fullscreen .time-display {
        font-size: clamp(60px, 17vw, 96px);
    }

    :fullscreen .phase-label,
    .pseudo-fullscreen .phase-label {
        font-size: clamp(16px, 4.8vw, 22px);
    }

    :fullscreen .meta-text,
    .pseudo-fullscreen .meta-text {
        font-size: clamp(12px, 3.6vw, 15px);
    }

    :fullscreen .controls,
    .pseudo-fullscreen .controls {
        width: min(100%, 360px);
        gap: 10px;
        margin-bottom: 0;
    }

    :fullscreen .btn-primary,
    .pseudo-fullscreen .btn-primary,
    :fullscreen .btn-secondary,
    .pseudo-fullscreen .btn-secondary {
        min-width: 96px;
        padding: 10px 16px;
        font-size: 14px;
    }

    :fullscreen .interrupt-group,
    .pseudo-fullscreen .interrupt-group {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
        gap: 8px;
    }

    :fullscreen .interrupt-count,
    .pseudo-fullscreen .interrupt-count {
        width: 100%;
        text-align: center;
        margin-top: -2px;
    }

    :fullscreen .exit-fullscreen-btn,
    .pseudo-fullscreen .exit-fullscreen-btn {
        top: max(10px, env(safe-area-inset-top));
        right: max(10px, env(safe-area-inset-right));
        padding: 8px 12px;
        font-size: 12px;
        z-index: 5;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
        scroll-behavior: auto !important;
    }
}
    
