.button {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3xs);
    padding: var(--space-3xs) var(--space-xs);
    background: var(--surface-raised);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color var(--transition), background-color var(--transition);
}

.button:hover {
    border-color: var(--action-hover);
}

.button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.button--primary {
    background: var(--action);
    border-color: var(--action);
    color: var(--ink-on-action);
}

.button--primary:hover:not(:disabled) {
    background: var(--action-hover);
    border-color: var(--action-hover);
}

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

.button--danger:hover:not(:disabled) {
    border-color: var(--danger);
}

.icon {
    width: 1.25rem;
    height: 1.25rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Theme toggle: CSS reads data-theme for the icon and the accessible name, so JS writes one attribute. */
.theme {
    padding: var(--space-3xs);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius);
    color: var(--ink-muted);
    cursor: pointer;
}

.theme:hover {
    border-color: var(--rule);
    color: var(--ink);
}

.theme__icon,
.theme__label {
    display: none;
}

.theme__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    white-space: nowrap;
    clip-path: inset(50%);
}

:root:not([data-theme]) .theme__icon[data-value='system'],
:root[data-theme='light'] .theme__icon[data-value='light'],
:root[data-theme='dark'] .theme__icon[data-value='dark'],
:root:not([data-theme]) .theme__label[data-value='system'],
:root[data-theme='light'] .theme__label[data-value='light'],
:root[data-theme='dark'] .theme__label[data-value='dark'] {
    display: block;
}

.search {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2xs);
}

.search__keyword,
.search__actions {
    grid-column: 1 / -1;
}

.search__actions {
    display: flex;
    justify-content: space-between;
    gap: var(--space-2xs);
}

.note-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    border-top: 1px solid var(--rule);
}

.note-list__item {
    display: block;
    width: 100%;
    padding: var(--space-2xs) var(--space-xs);
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--rule);
    text-align: left;
    cursor: pointer;
}

.note-list__item:hover {
    background: var(--surface-sunken);
}

.note-list__item[aria-current='true'] {
    background: var(--surface-raised);
    box-shadow: inset 3px 0 0 var(--accent);
}

.note-list__title {
    display: block;
    overflow: hidden;
    color: var(--ink-strong);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.note-list__meta {
    display: block;
    font-size: var(--step--1);
    color: var(--ink-faint);
}

.note-list__empty {
    padding: var(--space-s) var(--space-xs);
    color: var(--ink-faint);
}

.editor {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: var(--space-xs);
    min-height: 0;
}

.editor__title {
    font-size: var(--step-1);
}

.editor__body {
    flex: 1;
    min-height: 16rem;
    resize: none;
    font-family: var(--font-mono);
    font-size: var(--step--1);
    line-height: 1.55;
    tab-size: 4;
}

.editor__toolbar {
    display: flex;
    align-items: center;
    gap: var(--space-2xs);
}

.editor__dirty {
    margin-left: auto;
    font-size: var(--step--1);
    color: var(--accent);
}

.audit {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3xs) var(--space-m);
    font-size: var(--step--1);
    color: var(--ink-faint);
}

.audit dt {
    display: inline;
}

.audit dd {
    display: inline;
    margin-left: var(--space-3xs);
    color: var(--ink-muted);
}

.status {
    min-height: 1.5em;
    font-size: var(--step--1);
    color: var(--ink-muted);
}

.status[data-kind='error'] {
    color: var(--danger);
}

.card {
    display: grid;
    gap: var(--space-s);
    max-width: 24rem;
    padding: var(--space-m);
    background: var(--surface-sunken);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    text-align: center;
}
