/* Tools hub - administration */

.adm {
    max-width: 860px;
    margin: 0 auto;
    padding: 20px 16px calc(64px + var(--safe-bottom));
}

/* ---------- shared controls ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 36px;
    padding: 0 14px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 0.86rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
}

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

.btn:disabled {
    opacity: 0.45;
    cursor: default;
}

.btn .ic {
    font-size: 16px;
}

.btn-primary {
    border-color: var(--accent);
    background: var(--accent);
    color: var(--accent-ink);
    font-weight: 600;
}

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

.btn-danger {
    border-color: transparent;
    background: transparent;
    color: var(--danger);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.12);
}

.btn-block {
    width: 100%;
    height: 42px;
}

.field {
    display: block;
    margin-bottom: 14px;
}

.field > span {
    display: block;
    margin-bottom: 6px;
    font-size: 0.78rem;
    color: var(--text-dim);
}

.field input[type="text"],
.field input[type="password"],
.field input[type="search"],
.field select,
.field textarea {
    width: 100%;
    min-height: 40px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--bg);
    font-size: 16px;
    outline: none;
}

.field textarea {
    resize: vertical;
    line-height: 1.4;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    border-color: var(--accent);
}

.check {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 36px;
    font-size: 0.9rem;
    cursor: pointer;
}

.check input {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

.spacer {
    flex: 1;
}

/* ---------- login ---------- */

.adm-login {
    max-width: 340px;
    margin: 12vh auto 0;
    padding: 24px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
}

.adm-login h1 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    font-size: 1.05rem;
}

.adm-error,
.adm-note {
    margin-bottom: 14px;
    font-size: 0.84rem;
    color: var(--danger);
}

.adm-note {
    color: var(--text-dim);
}

/* ---------- header bits ---------- */

.adm-dirty {
    font-size: 0.78rem;
    color: var(--warning);
    white-space: nowrap;
}

/* ---------- tabs ---------- */

.adm-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
    scrollbar-width: none;
}

.adm-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 12px;
    border: 0;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    background: none;
    color: var(--text-dim);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
}

.adm-tab:hover {
    color: var(--text);
}

.adm-tab[aria-selected="true"] {
    color: var(--text);
    border-bottom-color: var(--accent);
}

.adm-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.adm-hint {
    font-size: 0.8rem;
    color: var(--text-dim);
}

.adm-card {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

.adm-card .field:last-child {
    margin-bottom: 0;
}

/* ---------- lists ---------- */

.adm-group-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 20px 0 8px;
    font-size: 0.74rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-dim);
}

.adm-group-title:first-child {
    margin-top: 0;
}

.adm-group {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    overflow: hidden;
    min-height: 46px;
}

.adm-group.is-drop-target {
    border-color: var(--accent);
}

.adm-empty {
    padding: 13px 14px;
    font-size: 0.82rem;
    color: var(--text-dim);
}

.adm-row {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 52px;
    padding: 6px 6px 6px 4px;
    border-bottom: 1px solid var(--line);
}

.adm-row:last-child {
    border-bottom: 0;
}

.adm-row.is-off .adm-row-icon,
.adm-row.is-off .adm-row-body {
    opacity: 0.45;
}

.adm-row.is-dragging {
    opacity: 0.35;
}

.adm-row.drop-before::before,
.adm-row.drop-after::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent);
}

.adm-row.drop-before::before {
    top: -1px;
}

.adm-row.drop-after::after {
    bottom: -1px;
}

.adm-grip {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 36px;
    color: var(--line-strong);
    cursor: grab;
    flex: none;
}

.adm-row-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    flex: none;
    border-radius: 8px;
    background: var(--surface-2);
    font-size: 16px;
}

.adm-row-body {
    flex: 1;
    min-width: 0;
}

.adm-row-title {
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.adm-row-meta {
    font-size: 0.74rem;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.adm-row-actions {
    display: flex;
    flex: none;
}

.adm-row-actions .hub-btn {
    padding: 0;
    width: 36px;
}

.adm-row-actions .hub-btn:disabled {
    opacity: 0.25;
    cursor: default;
    background: none;
}

/* ---------- dialogs ---------- */

.adm-dialog {
    width: min(520px, calc(100vw - 20px));
    max-height: calc(100dvh - 20px);
    margin: auto;
    padding: 0;
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    overflow: hidden;
}

.adm-dialog::backdrop {
    background: rgba(0, 0, 0, 0.6);
}

.adm-dialog form {
    display: flex;
    flex-direction: column;
    max-height: calc(100dvh - 22px);
}

.adm-dialog header,
.adm-dialog footer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px 10px 18px;
    flex: none;
}

.adm-dialog header {
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
}

.adm-dialog header h2 {
    font-size: 1rem;
}

.adm-dialog footer {
    padding: 12px 18px;
    border-top: 1px solid var(--line);
}

.adm-dialog-body {
    padding: 18px;
    overflow-y: auto;
}

/* ---------- icon picker ---------- */

.icon-current {
    display: flex;
    align-items: center;
    gap: 10px;
}

.icon-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex: none;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--bg);
    font-size: 19px;
}

.icon-preview img {
    width: 20px;
    height: 20px;
}

.icon-panel {
    margin-top: 10px;
}

.icon-panel input[type="search"] {
    margin-bottom: 8px;
}

.icon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    gap: 4px;
    max-height: 176px;
    overflow-y: auto;
    padding: 2px;
}

.icon-grid button {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--text);
    font-size: 18px;
    cursor: pointer;
}

.icon-grid button:hover {
    background: var(--surface-2);
}

.icon-grid button[aria-pressed="true"] {
    border-color: var(--accent);
    color: var(--accent);
}

.icon-svg-input {
    margin-top: 10px;
    font-family: var(--mono);
    font-size: 12px !important;
}

@media (max-width: 640px) {
    .adm {
        padding: 14px 10px calc(64px + var(--safe-bottom));
    }

    .adm-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .adm-grip,
    .adm-dirty {
        display: none;
    }

    .adm-row {
        padding-left: 10px;
    }

    #admSave span {
        display: none;
    }

    #admSave {
        padding: 0 10px;
    }
}

.adm-row-title,
.adm-row-meta {
    display: block;
}

/* ---------- theme controls ---------- */

.adm-panel > .adm-group-title {
    margin-top: 24px;
}

.theme-swatches,
.theme-tones {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.theme-swatch {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 2px solid var(--surface);
    border-radius: 50%;
    background: var(--sw, var(--surface-2));
    outline: 1px solid var(--line-strong);
    cursor: pointer;
    font-size: 15px;
    color: var(--text);
}

.theme-swatch[aria-checked="true"],
.theme-swatch-custom.is-on {
    outline: 2px solid var(--text);
}

.theme-swatch-custom.is-on {
    background: var(--accent);
    color: var(--accent-ink);
}

.theme-swatch-custom input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.theme-tone {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 38px;
    padding: 0 12px 0 6px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text-dim);
    font-size: 0.84rem;
    cursor: pointer;
}

.theme-tone[aria-checked="true"] {
    border-color: var(--accent);
    color: var(--text);
}

.theme-tone-chip {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border: 1px solid var(--t-line);
    border-radius: 6px;
    background: var(--t-bg);
}

.theme-tone-chip i {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    background: var(--t-surface);
    border: 1px solid var(--t-line);
}

.theme-seg {
    display: inline-flex;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.theme-seg button {
    height: 36px;
    padding: 0 14px;
    border: 0;
    border-right: 1px solid var(--line);
    background: var(--bg);
    color: var(--text-dim);
    font-size: 0.84rem;
    cursor: pointer;
}

.theme-seg button:last-child {
    border-right: 0;
}

.theme-seg button[aria-checked="true"] {
    background: var(--surface-2);
    color: var(--text);
}

/* ---------- card colour and image ---------- */

.card-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.card-color {
    width: 44px;
    height: 36px;
    padding: 2px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: var(--bg);
    cursor: pointer;
}

.card-state {
    flex: 1;
    min-width: 0;
    font-size: 0.8rem;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-preview {
    margin-top: 10px;
    max-width: 360px;
    overflow: hidden;
}

.card-preview .tool-item-link {
    padding-right: 12px;
}

.card-swatches {
    margin-bottom: 10px;
}

.card-swatches .theme-swatch {
    width: 28px;
    height: 28px;
}
