/* === THEMES === */
[data-theme="midnight"] {
    --bg-color: #0b132b;
    --card-bg: #1c2541;
    --tracker-bg: #4a154b;
    --tracker-bg-done: #2d6a4f;
    --text-main: #ffffff;
    --text-muted: #a1a1aa;
    --accent: #3a506b;
    --btn-hover: #5bc0be;
    --btn-highlight: #f72585;
    --btn-highlight-rgb: 247, 37, 133;
    --note-bg: #4d5059;
    --note-inline: #8be9fd;
}

[data-theme="dark"] {
    --bg-color: #0e0e0e;
    --card-bg: #1c1c1c;
    --tracker-bg: #2a2a2a;
    --tracker-bg-done: #3d3d3d;
    --text-main: #ffffff;
    --text-muted: #a0a0a0;
    --accent: #4a4a4a;
    --btn-hover: #909090;
    --btn-highlight: #d0d0d0;
    --btn-highlight-rgb: 208, 208, 208;
    --note-bg: #3a3a3a;
    --note-inline: #a0c0d0;
}

* { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    margin: 0;
    padding: 10px;
    display: flex;
    justify-content: center;
}

#app {
    width: 100%;
    max-width: 450px;
    height: 98dvh;
    display: flex;
    flex-direction: column;
}

.view {
    display: none;
    flex-direction: column;
    gap: 12px;
    flex-grow: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 10px;
}

.view.active { display: flex; }
.view::-webkit-scrollbar { display: none; } 
.view { -ms-overflow-style: none; scrollbar-width: none; } 

h1, h2, h3 { margin: 0; }

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0; 
}

.form-group label {
    font-size: 14px;
    color: var(--text-muted);
}

input, textarea, button {
    font-family: inherit;
    border-radius: 8px;
    border: none;
    padding: 12px;
    font-size: 16px;
    flex-shrink: 0; 
}

input, textarea {
    background-color: var(--card-bg);
    color: white;
    border: 1px solid var(--accent);
}

textarea { resize: vertical; min-height: 120px; }

button {
    background-color: var(--accent);
    color: white;
    cursor: pointer;
    font-weight: bold;
    transition: 0.2s;
}

button:hover { filter: brightness(1.2); }

.long-btn {
    width: 100%;
    padding: 14px;
    font-size: 18px;
    background-color: var(--btn-hover);
    color: var(--bg-color);
    border-radius: 10px;
    margin-bottom: 5px;
}

.import-row {
    display: flex;
    gap: 10px;
}

.import-row button, .import-row label {
    flex: 1;
    text-align: center;
    background-color: var(--accent);
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 14px;
}

.color-toolbar {
    display: grid;
    grid-template-rows: repeat(2, 1fr);
    grid-auto-flow: column;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 5px;
    flex-shrink: 0; 
    min-height: 75px; 
}

.color-toolbar::-webkit-scrollbar { display: none; }

.color-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.3);
    cursor: pointer;
    flex-shrink: 0;
    transition: 0.2s;
}

.color-btn:hover { transform: scale(1.15); border-color: white; }

/* Grid for Projects */
.project-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.project-tassel {
    background-color: var(--card-bg);
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--accent);
    transition: 0.2s;
    aspect-ratio: 0.8;
}

.project-tassel:hover { filter: brightness(1.1); transform: translateY(-2px); }

.tassel-name {
    font-size: 12px;
    font-weight: bold;
    padding: 6px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background-color: rgba(0,0,0,0.2);
}

.tassel-img {
    flex-grow: 1;
    background-color: var(--bg-color);
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    position: relative;
    border-bottom: 1px solid var(--accent);
}

.tassel-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px;
    background-color: var(--card-bg);
}

.tassel-percent {
    font-size: 11px;
    font-weight: bold;
    color: var(--text-muted);
}

.tassel-actions {
    display: flex;
    gap: 6px;
}

.action-icon {
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

.action-icon svg { pointer-events: none; width: 16px; height: 16px; }
.action-icon:hover { transform: scale(1.2); }
.action-icon.export:hover { color: var(--btn-hover); }
.action-icon.delete:hover { color: var(--text-main); }
.action-icon.edit-row:hover { color: var(--btn-hover); }

/* Photo Grid */
.photo-grid {
    display: flex;
    gap: 10px;
    justify-content: space-between;
}

.photo-slot {
    flex: 1;
    aspect-ratio: 1;
    background-color: var(--tracker-bg);
    border: 2px dashed var(--accent);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.photo-slot-empty {
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
}

.photo-controls {
    position: absolute;
    bottom: 0;
    width: 100%;
    display: flex;
    justify-content: space-around;
    background: rgba(0,0,0,0.6);
    padding: 4px 0;
    opacity: 0;
    transition: opacity 0.2s;
}

.photo-slot:hover .photo-controls { opacity: 1; }

.photo-controls button {
    background: none;
    border: none;
    color: white;
    padding: 4px;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.photo-controls button:hover { transform: scale(1.2); }

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.docs-link {
    color: var(--btn-hover);
    font-size: 16px;
    text-decoration: none;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 6px;
}

.docs-link:hover { filter: brightness(1.2); }

.nav-btn {
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    background-color: white;
    color: black;
    flex-shrink: 0;
}

.block-note-badge {
    background-color: var(--tracker-bg);
    color: white;
    padding: 6px 16px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 14px;
    margin-bottom: 8px;
    border: 2px solid var(--btn-hover);
    align-self: center;
    display: none;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.pattern-display {
    background-color: var(--accent);
    padding: 10px 12px;
    border-radius: 10px;
    text-align: center;
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 5px;
    cursor: pointer;
    user-select: none;
    touch-action: manipulation;
    transition: 0.2s;
}

.pattern-display:hover { filter: brightness(1.15); }

#segments-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tracker-notes-section {
    margin-top: auto;
    padding-top: 15px;
}

.tracker-notes-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-main);
    margin-bottom: 5px;
}

.eye-btn {
    background: none;
    border: none;
    padding: 0;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.eye-btn:hover { color: white; filter: none; transform: scale(1.1); }

.tracker-row-note-content {
    background-color: var(--note-bg);
    color: var(--text-main);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 8px;
    padding: 12px;
    font-size: 13.5px;
    min-height: 50px;
    width: 100%;
    resize: vertical;
    transition: 0.2s border-color;
}

.tracker-row-note-content:focus {
    outline: none;
    border-color: var(--btn-hover);
}

.segment-card {
    background-color: var(--tracker-bg);
    border: 2px dashed rgba(255,255,255,0.3);
    border-radius: 12px;
    padding: 8px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: 0.3s;
    min-width: 0;
    width: 100%;
}

.segment-card.done { background-color: var(--tracker-bg-done); border-style: solid; }

.segment-text {
    font-size: 16px;
    font-weight: bold;
    flex: 1 1 auto;
    padding-right: 8px;
    display: flex;
    align-items: center;
    min-width: 0;
    word-wrap: break-word;
    line-height: 1.25;
}

/* NEW Inline Note Style */
.step-note {
    font-size: 13.5px;
    color: var(--note-inline);
    font-weight: normal;
    margin-left: 6px;
    font-style: italic;
    opacity: 0.9;
    white-space: normal;
}

.segment-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.segment-counter {
    font-size: 18px;
    font-weight: bold;
    min-width: 40px;
    text-align: center;
}

.btn-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 20px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--accent);
    flex-shrink: 0;
}

.btn-circle.pulse {
    background-color: var(--btn-highlight);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(var(--btn-highlight-rgb), 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(var(--btn-highlight-rgb), 0); }
    100% { box-shadow: 0 0 0 0 rgba(var(--btn-highlight-rgb), 0); }
}

.group-layout { 
    display: flex; 
    gap: 6px; 
    align-items: center; 
    min-width: 0;
    width: 100%;
}

.group-segments { 
    flex: 1; 
    display: flex; 
    flex-direction: column; 
    gap: 6px; 
    position: relative;
    padding-right: 14px;
    padding-top: 2px; 
    padding-bottom: 2px;
    min-width: 0;
}

.group-segments::after {
    content: '';
    position: absolute;
    right: 2px;
    top: 0; 
    bottom: 0; 
    width: 10px;
    border: 3px solid var(--btn-hover);
    border-left: none; 
    border-radius: 0 10px 10px 0; 
    z-index: 0;
    pointer-events: none;
}

.group-controls {
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    gap: 4px;
    z-index: 1;
    flex-shrink: 0;
}

.bracket-btn {
    width: 28px !important;
    height: 28px !important;
    font-size: 16px !important;
}

.bracket-counter {
    font-size: 16px !important;
    min-width: 35px !important;
}

.row-list-item {
    background-color: var(--card-bg); padding: 12px; margin-bottom: 8px;
    border-radius: 8px; cursor: pointer; display: flex; justify-content: space-between;
}

.row-list-item:hover { background-color: var(--accent); }
.row-list-item.row-done { border-left: 5px solid var(--tracker-bg-done); }

.modal-overlay {
    display: none;
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.8);
    justify-content: center; align-items: center;
    z-index: 1000;
}

.modal-content {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    border: 1px solid var(--accent);
    max-width: 320px; width: 90%;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    display: flex; flex-direction: column;
}

.modal-buttons {
    display: flex; gap: 10px; justify-content: center; margin-top: 15px;
}

.raw-data-textarea {
    width: 100%; height: 100px; font-family: monospace;
    font-size: 11px; margin-top: 10px; background-color: var(--bg-color);
    color: var(--text-muted); border: 1px solid var(--accent); resize: none;
}

.theme-toggle {
    background: none;
    border: 1px solid var(--text-muted);
    color: var(--text-main);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    padding: 0;
    cursor: pointer;
    flex-shrink: 0;
}

.theme-toggle:hover {
    border-color: var(--btn-hover);
    color: var(--btn-hover);
}

.modal-color-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    justify-items: center;
    margin-bottom: 15px;
}