:root[data-theme="light"] {
    --bg: #f6f7fb;
    --card: #fff;
    --codebg: #f2f0f0;
    --text: #111827;
    --muted: #6b7280;
    --border: #d1d5db;
    --accent: #7e25eb;
    --danger: #dc2626;
}

:root[data-theme="dark"] {
    --bg: #221233;
    --card: #210c37;
    --codebg: #2b2b2b;
    --text: #e5e7eb;
    --muted: #94a3b8;
    --border: #334155;
    --accent: #a838f8;
    --danger: #f87171;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arianl, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    transition: all 0.2s;
}

header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    transition: all 0.2s;
}

h1 {
    margin: 0;
    font-size: 24px;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

input,
select,
textarea,
button {
    font: inherit;
    border-radius: 8px;
    border: 1px solid var(--border);
    padding: 8px 10px;
    background-color: var(--bg);
    color: var(--text);
    transition: all 0.2s;
}

input:hover,
textarea:hover {
    border: 1px solid var(--accent);
}

input:focus,
textarea:focus {
    outline: none;
    border: 2px solid var(--accent);
}

textarea {
    width: 100%;
    min-height: 160px;
    resize: vertical;
    font-family: monospace;
}

button {
    cursor: pointer;
}

button:hover {
    color: #fcfcfc;
    background-color: var(--accent);
    transform: scale(1.1);
}

button:active {
    transform: scale(0.9);
}

main {
    padding: 16px;
    display: grid;
    gap: 16px;
    transition: all 0.2s;
}

.card {
    background-color: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    transition: all 0.2s;
}

.form-grid {
    display: grid;
    gap: 10px;
}

.form-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.snippet-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(500px, 1fr));
    gap: 16px;
    align-items: stretch;
}

.snippet-list .card {
    display: flex;
    flex-direction: column;
    cursor: pointer;
}

.snippet-list .card:hover {
    border: 1px solid var(--accent);
    transform: translateY(-2px) scale(1.04);
}


.snippet-top {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 12px;
}

.snippet-title {
    margin: 0;
    font-size: 18px;
    word-break: break-word;
}

.snippet-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    width: max-content;
}

.snippet-action {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.badge {
    padding: 4px 8px;
    border-radius: 999px;
}

pre {
    margin: 0;
    border-radius: 10px;
    overflow: auto;
    max-height: 250px;
    flex: 1;
    cursor: text;
    transition: all 0.2s;
}

pre code.hljs {
    background-color: var(--codebg);
    border-radius: 10px;
    padding: 14px;
    transition: all 0.2s;
}

.card.is-pinned {
    border: 2px solid var(--accent);
}

.pin-bridge {
    background-color: var(--accent);
    color: #fff;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: bold;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: all 0.2s;
}

.modal-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 600px;
    overflow: hidden;
}

.palette-card {
    padding: 12px;
}

#paletteSearch {
    width: 100%;
    font-size: 16px;
    padding: 12px;
    margin-bottom: 8px;
}

.palette-results {
    list-style: none;
    padding: 2px;
    margin: 0;
    max-height: 300px;
    overflow-y: auto;
}

.palette-results li {
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.palette-results li:hover,
.palette-results li:focus {
    background-color: var(--bg);
}

#paletteResults li.active {
    background-color: var(--codebg);
    outline: 2px solid var(--accent);
}

.shortcut-hint {
    font-size: 12px;
    color: var(--muted);
}

.reader-card {
    max-width: 1000px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    margin: 0;
    font-size: 20px;
}

.close-btn {
    background: transparent;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 0 8px;
}

.reader-body {
    padding: 16px;
    overflow-y: auto;
}

.reader-body pre {
    max-height: none;
}

#export-canvas-container {
    position: absolute;
    left: -9999px;
    top: -9999px;
}

.export-card-wrapper {
    padding: 10px;
    background: linear-gradient(135deg, #7e25eb 0%, #3b82f6 100%);
    border-radius: 16px;
    width: 600px;
    box-sizing: border-box;
}

.export-card-window {
    padding: 10px;
    background: var(--card);
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
    overflow: hidden;
    border: 1px solid var(--border);
}

export-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background-color: var(--bg);
    border-bottom: 1px solid var(--border);
}

.mac-dots {
    display: flex;
    gap: 6px;
}

.mac-dots span {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.dot-red {
    background-color: #ff5f56;
}

.dot-yellow {
    background-color: #ffbd2e;
}

.dot-green {
    background-color: #27c93f;
}

.export-card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.export-card-body pre {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-all;
    font-family: monospace;
    color: var(--text);
    font-size: 14px;
}

.danger {
    color: var(--danger);
}

.danger:hover {
    color: #fcfcfc;
    background-color: var(--danger);
}

.empty {
    grid-column: 1 / -1;
    color: var(--muted);
    padding: 24px;
    text-align: center;
    border: 1px dashed var(--border);
    border-radius: 12px;
}

#saveBtn {
    color: #fcfcfc;
    background-color: var(--accent);
}

[hidden] {
  display: none !important;
}
