/* OS-2045 Wave B — Mini-Apps Polish.
 *
 * Styles for Notes (multi-note + markdown preview), Calculator (scientific +
 * memory + history) and Color-Picker (HSL/RGB tabs + harmonies + palettes).
 * All scoped under [data-theme-mode="os2045"] so the Win3.11 / classic themes
 * stay untouched.
 */

[data-theme-mode="os2045"] {

    /* ─── Notes ─────────────────────────────────────────────────────────── */
    .notes-root {
        display: flex;
        height: 100%;
        background: #0a0a0a;
        color: var(--theme-color);
        font-family: 'JetBrains Mono', 'Courier New', monospace;
    }
    .notes-sidebar {
        width: 180px;
        min-width: 140px;
        max-width: 240px;
        border-right: 1px solid var(--theme-color-dark);
        display: flex;
        flex-direction: column;
        background: rgba(0, 0, 0, 0.4);
    }
    .notes-sidebar-head {
        padding: 8px;
        border-bottom: 1px solid var(--theme-color-dark);
        display: flex;
        gap: 6px;
    }
    .notes-new-btn {
        flex: 1;
        background: var(--theme-color-dark);
        color: var(--theme-color);
        border: 1px solid var(--theme-color-dark);
        padding: 5px 8px;
        cursor: pointer;
        border-radius: 3px;
        font-size: 0.8rem;
        font-family: inherit;
    }
    .notes-new-btn:hover { background: var(--theme-color-dim); color: #000; }
    .notes-list {
        flex: 1;
        overflow-y: auto;
        padding: 4px;
    }
    .notes-list-item {
        padding: 6px 8px;
        margin: 2px 0;
        cursor: pointer;
        border-radius: 3px;
        border: 1px solid transparent;
        font-size: 0.8rem;
        color: var(--theme-color-dim);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .notes-list-item:hover { background: rgba(255, 255, 255, 0.05); }
    .notes-list-item.active {
        background: var(--theme-color-dark);
        color: var(--theme-color);
        border-color: var(--theme-color-dim);
    }
    .notes-list-item .notes-item-title { display: block; font-weight: 600; }
    .notes-list-item .notes-item-mtime { display: block; font-size: 0.65rem; opacity: 0.6; }
    .notes-list-item .notes-item-del {
        float: right;
        background: none;
        border: none;
        color: #c66;
        cursor: pointer;
        font-size: 0.9rem;
        padding: 0 2px;
    }
    .notes-list-item .notes-item-del:hover { color: #f00; }

    .notes-main {
        flex: 1;
        display: flex;
        flex-direction: column;
        min-width: 0;
    }
    .notes-toolbar {
        padding: 6px 10px;
        border-bottom: 1px solid var(--theme-color-dark);
        display: flex;
        align-items: center;
        gap: 8px;
        flex-wrap: wrap;
    }
    .notes-title-input {
        flex: 1;
        background: transparent;
        border: 1px solid transparent;
        color: var(--theme-color);
        padding: 4px 6px;
        font-family: inherit;
        font-size: 0.95rem;
        outline: none;
        min-width: 80px;
    }
    .notes-title-input:focus { border-color: var(--theme-color-dim); }
    .notes-toolbar-btn {
        background: transparent;
        border: 1px solid var(--theme-color-dark);
        color: var(--theme-color-dim);
        padding: 4px 8px;
        cursor: pointer;
        border-radius: 3px;
        font-family: inherit;
        font-size: 0.75rem;
    }
    .notes-toolbar-btn:hover { color: var(--theme-color); border-color: var(--theme-color-dim); }
    .notes-toolbar-btn.active { background: var(--theme-color-dark); color: var(--theme-color); }
    .notes-save-indicator {
        font-size: 0.7rem;
        color: var(--theme-color-dim);
        min-width: 90px;
        text-align: right;
    }
    .notes-save-indicator.saving { color: #f0c060; }
    .notes-save-indicator.saved { color: var(--theme-color); }

    .notes-edit, .notes-preview {
        flex: 1;
        overflow: auto;
        padding: 14px;
        font-family: inherit;
        font-size: 0.9rem;
        line-height: 1.55;
    }
    .notes-edit {
        background: transparent;
        border: none;
        color: var(--theme-color);
        outline: none;
        resize: none;
    }
    .notes-preview {
        background: rgba(0, 0, 0, 0.3);
        color: var(--theme-color);
    }
    .notes-preview h1, .notes-preview h2, .notes-preview h3 {
        color: var(--theme-color);
        margin: 0.6em 0 0.3em;
    }
    .notes-preview a { color: var(--theme-color); text-decoration: underline; }
    .notes-preview code {
        background: rgba(255, 255, 255, 0.08);
        padding: 1px 4px;
        border-radius: 2px;
    }
    .notes-preview ul { padding-left: 1.4em; }
    .notes-preview p { margin: 0.4em 0; }
    .notes-footer {
        padding: 4px 10px;
        border-top: 1px solid var(--theme-color-dark);
        font-size: 0.7rem;
        color: var(--theme-color-dim);
        display: flex;
        justify-content: space-between;
    }

    /* ─── Calculator ────────────────────────────────────────────────────── */
    .calc-root {
        display: flex;
        height: 100%;
        background: #0a0a0a;
    }
    .calc-main {
        flex: 1;
        display: flex;
        flex-direction: column;
        padding: 10px;
        min-width: 260px;
    }
    .calc-toolbar {
        display: flex;
        gap: 6px;
        margin-bottom: 6px;
        align-items: center;
        flex-wrap: wrap;
    }
    .calc-toolbar-btn {
        background: transparent;
        border: 1px solid var(--theme-color-dark);
        color: var(--theme-color-dim);
        padding: 3px 8px;
        cursor: pointer;
        border-radius: 3px;
        font-size: 0.7rem;
        font-family: 'JetBrains Mono', monospace;
    }
    .calc-toolbar-btn.active { background: var(--theme-color-dark); color: var(--theme-color); border-color: var(--theme-color-dim); }
    .calc-display-wrap {
        background: #111;
        border: 1px solid var(--theme-color-dark);
        border-radius: 3px;
        padding: 8px 12px;
        margin-bottom: 8px;
        text-align: right;
    }
    .calc-preview {
        font-size: 0.8rem;
        color: var(--theme-color-dim);
        font-family: 'JetBrains Mono', monospace;
        min-height: 1em;
        opacity: 0.85;
    }
    .calc-display {
        width: 100%;
        background: transparent;
        border: none;
        color: var(--theme-color);
        font-family: 'JetBrains Mono', monospace;
        font-size: 1.7rem;
        text-align: right;
        outline: none;
        padding: 0;
    }
    .calc-grid {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 5px;
        flex: 1;
    }
    .calc-grid.scientific { grid-template-columns: repeat(5, 1fr); }
    .calc-btn {
        border: none;
        background: #222;
        color: var(--theme-color);
        font-size: 1rem;
        cursor: pointer;
        border-radius: 3px;
        font-family: 'JetBrains Mono', monospace;
        transition: background 0.15s, opacity 0.1s;
        padding: 6px;
    }
    .calc-btn:hover { opacity: 0.85; }
    .calc-btn.op { background: var(--theme-color); color: #000; font-weight: 600; }
    .calc-btn.fn { background: #333; color: var(--theme-color-dim); font-size: 0.85rem; }
    .calc-btn.mem { background: #2a2a3a; color: var(--theme-color); font-size: 0.8rem; }
    .calc-btn:disabled { opacity: 0.4; cursor: not-allowed; }

    .calc-history {
        width: 180px;
        min-width: 140px;
        border-left: 1px solid var(--theme-color-dark);
        display: flex;
        flex-direction: column;
        background: rgba(0, 0, 0, 0.4);
    }
    .calc-history-head {
        padding: 6px 8px;
        border-bottom: 1px solid var(--theme-color-dark);
        font-size: 0.75rem;
        color: var(--theme-color-dim);
        display: flex;
        justify-content: space-between;
    }
    .calc-history-clear {
        background: none;
        border: none;
        color: #c66;
        cursor: pointer;
        font-size: 0.7rem;
    }
    .calc-history-list {
        flex: 1;
        overflow-y: auto;
        padding: 4px;
    }
    .calc-history-item {
        padding: 4px 6px;
        cursor: pointer;
        border-radius: 2px;
        font-family: 'JetBrains Mono', monospace;
        font-size: 0.75rem;
        color: var(--theme-color);
        margin: 2px 0;
        text-align: right;
    }
    .calc-history-item:hover { background: rgba(255, 255, 255, 0.06); }
    .calc-history-item .calc-history-expr { display: block; font-size: 0.65rem; color: var(--theme-color-dim); }

    /* ─── Color Picker ──────────────────────────────────────────────────── */
    .cp-root {
        display: flex;
        flex-direction: column;
        height: 100%;
        padding: 12px;
        gap: 10px;
        background: #0a0a0a;
        color: var(--theme-color);
        font-family: 'Inter', sans-serif;
    }
    .cp-tabs {
        display: flex;
        gap: 4px;
        border-bottom: 1px solid var(--theme-color-dark);
    }
    .cp-tab {
        padding: 5px 12px;
        background: transparent;
        border: none;
        border-bottom: 2px solid transparent;
        color: var(--theme-color-dim);
        cursor: pointer;
        font-family: inherit;
        font-size: 0.8rem;
    }
    .cp-tab.active {
        color: var(--theme-color);
        border-bottom-color: var(--theme-color);
    }
    .cp-input-row {
        display: flex;
        gap: 6px;
        align-items: center;
    }
    .cp-input-row label {
        width: 18px;
        font-size: 0.75rem;
        color: var(--theme-color-dim);
        font-family: 'JetBrains Mono', monospace;
    }
    .cp-input-row input[type="text"],
    .cp-input-row input[type="number"] {
        flex: 1;
        background: #111;
        border: 1px solid var(--theme-color-dark);
        color: var(--theme-color);
        padding: 4px 6px;
        font-family: 'JetBrains Mono', monospace;
        font-size: 0.85rem;
        border-radius: 3px;
        outline: none;
        min-width: 0;
    }
    .cp-input-row input:focus { border-color: var(--theme-color-dim); }
    .cp-copy-btn {
        background: transparent;
        border: 1px solid var(--theme-color-dark);
        color: var(--theme-color-dim);
        padding: 3px 8px;
        cursor: pointer;
        border-radius: 3px;
        font-size: 0.7rem;
    }
    .cp-copy-btn:hover { color: var(--theme-color); border-color: var(--theme-color-dim); }
    .cp-row {
        display: flex;
        gap: 8px;
        align-items: center;
        flex-wrap: wrap;
    }
    .cp-swatch {
        width: 60px;
        height: 60px;
        border: 1px solid var(--theme-color-dark);
        border-radius: 4px;
        cursor: pointer;
        flex-shrink: 0;
    }
    .cp-presets {
        display: flex;
        gap: 6px;
        flex-wrap: wrap;
    }
    .cp-preset {
        width: 24px;
        height: 24px;
        border: 2px solid #333;
        border-radius: 50%;
        cursor: pointer;
        padding: 0;
        transition: transform 0.15s;
    }
    .cp-preset:hover { transform: scale(1.15); border-color: #fff; }
    .cp-section-label {
        font-size: 0.7rem;
        color: var(--theme-color-dim);
        text-transform: uppercase;
        letter-spacing: 0.05em;
        margin-top: 4px;
    }
    .cp-harmonies {
        display: flex;
        gap: 6px;
        flex-wrap: wrap;
    }
    .cp-harmony {
        flex: 1;
        min-width: 0;
        text-align: center;
        background: transparent;
        border: 1px solid var(--theme-color-dark);
        border-radius: 4px;
        padding: 4px;
        cursor: pointer;
        color: var(--theme-color);
        font-size: 0.7rem;
        font-family: inherit;
    }
    .cp-harmony:hover { border-color: var(--theme-color-dim); }
    .cp-harmony-swatches {
        display: flex;
        gap: 2px;
        height: 16px;
        margin-bottom: 3px;
        border-radius: 2px;
        overflow: hidden;
    }
    .cp-harmony-swatches > span {
        flex: 1;
        display: block;
    }
    .cp-palettes {
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        gap: 6px;
    }
    .cp-palette-slot {
        aspect-ratio: 1;
        border: 1px dashed var(--theme-color-dark);
        border-radius: 3px;
        cursor: pointer;
        background: transparent;
        position: relative;
    }
    .cp-palette-slot.filled { border-style: solid; }
    .cp-palette-slot .cp-slot-clear {
        position: absolute;
        top: -4px;
        right: -4px;
        width: 14px;
        height: 14px;
        background: #c33;
        color: #fff;
        border: none;
        border-radius: 50%;
        cursor: pointer;
        font-size: 0.6rem;
        line-height: 1;
        display: none;
    }
    .cp-palette-slot.filled:hover .cp-slot-clear { display: block; }
    .cp-actions {
        display: flex;
        gap: 8px;
        margin-top: auto;
    }
    .cp-btn {
        flex: 1;
        padding: 8px;
        cursor: pointer;
        border-radius: 4px;
        font-family: inherit;
        font-size: 0.85rem;
        font-weight: 600;
    }
    .cp-btn-primary {
        background: var(--theme-color);
        color: #000;
        border: none;
    }
    .cp-btn-secondary {
        background: transparent;
        color: var(--theme-color-dim);
        border: 1px solid var(--theme-color-dark);
    }
    .cp-btn-secondary:hover { color: var(--theme-color); }

    .cp-live-toggle {
        display: flex;
        align-items: center;
        gap: 6px;
        font-size: 0.75rem;
        color: var(--theme-color-dim);
    }

    /* Reduced motion */
    .os-reduced-motion .cp-preset,
    .os-reduced-motion .calc-btn { transition: none !important; }
}
