/* ==========================================================================
   Base: reset and shared primitives (buttons, inputs, icons)
   ========================================================================== */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-ui);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

button {
    cursor: pointer;
}

button:disabled {
    cursor: default;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

svg {
    flex: none;
}

[hidden] {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* --- Buttons ------------------------------------------------------------ */

.btn-ink {
    height: 36px;
    padding: 0 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 0;
    border-radius: var(--radius-control);
    background: var(--ink);
    color: var(--on-ink);
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    transition: background-color 0.15s ease;
}

.btn-ink:hover {
    background: var(--ink-hover);
}

.btn-ghost {
    height: 36px;
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-control);
    background: var(--surface);
    color: var(--text-control);
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    transition: background-color 0.15s ease;
}

.btn-ghost:hover {
    background: var(--hover);
}

.icon-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-grid;
    place-items: center;
    border: 0;
    border-radius: var(--radius-control);
    background: transparent;
    color: var(--text-control);
    transition: background-color 0.15s ease;
}

.icon-btn:hover {
    background: var(--hover-strong);
}

/* --- Segmented control -------------------------------------------------- */

.segmented {
    display: flex;
    gap: 2px;
    padding: 3px;
    background: var(--segment-bg);
    border-radius: 11px;
}

.segmented > button {
    height: 28px;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.segmented > button:hover {
    color: var(--text);
}

.segmented > button[aria-pressed="true"] {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-segment);
}

/* Icon-only segments (view mode) */
.segmented-icon > button {
    width: 30px;
    padding: 0;
}

/* Full-width segments (table alignment) */
.segmented-sm {
    border-radius: var(--radius-control);
}

.segmented-sm > button {
    flex: 1;
    height: 30px;
}

.segmented-sm > button[aria-pressed="true"] {
    box-shadow: 0 1px 2px rgba(17, 24, 26, 0.08);
}

/* --- Inputs -------------------------------------------------------------- */

.field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.field-label {
    font-size: 12.5px;
    color: var(--muted);
}

.input {
    width: 100%;
    height: 38px;
    padding: 0 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-control);
    background: var(--surface-sunken);
    color: var(--text);
    font-size: 14px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.input:focus,
.input:focus-visible {
    outline: none;
    border-color: var(--accent);
    background: var(--surface);
    box-shadow: 0 0 0 0.5px var(--accent), 0 0 0 4px var(--accent-ring);
}

.input[aria-invalid="true"] {
    border-color: var(--danger);
    box-shadow: 0 0 0 0.5px var(--danger), 0 0 0 4px color-mix(in oklab, var(--danger) 14%, transparent);
}

.input-mono {
    font-family: var(--font-mono);
    font-size: 13px;
}

.check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-soft);
    cursor: pointer;
}

.check input {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--ink);
}
