/* ==========================================================================
   WorkFlowWizard - Free Flux Consulting
   Mobile-first: the base rules are for phones. Larger screens add to them:
     min-width 600px  tablet
     min-width 900px  desktop: the task list becomes a table with columns
   Mouse/trackpad-only extras (hover icons, hover lift) live under
   (hover: hover) and (pointer: fine), so touch screens of any size never depend on hover.
   ========================================================================== */

/* Free Flux Consulting Brand Colors */
:root {
    --orient-dark: #015474;
    --curious-blue: #2ba0c1;
    --neptune-grey: #81bab6;
    --cerulean-bright: #0C8ED7;
    --light-grey-blue: #dde6ec;
    --light-greyish: #99bdd7;
    --white: #ffffff;
    --border-color: #99bdd7;
    --text-dark: #015474;
    --text-light: #333333;
    --muted: #6b8797;
    --danger: #e74c3c;
    --danger-dark: #c0392b;
    --page-bg: #f5f7fa;
    --radius: 8px;
    --tap: 44px; /* minimum comfortable touch target */
    --indent-step: 14px; /* how far each subtask level is indented in the task list */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

html, body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--page-bg);
    color: var(--text-light);
}

body {
    min-height: 100vh;
    min-height: 100dvh;
    padding-bottom: env(safe-area-inset-bottom);
    -webkit-tap-highlight-color: rgba(12, 142, 215, 0.12);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 max(12px, env(safe-area-inset-left)) 24px max(12px, env(safe-area-inset-right));
}

button {
    font-family: inherit;
}

/* ============= HEADER ============= */
.header {
    background: linear-gradient(135deg, var(--orient-dark) 0%, var(--curious-blue) 100%);
    color: var(--white);
    padding: 14px 16px;
    padding-top: max(14px, env(safe-area-inset-top));
    box-shadow: 0 2px 8px rgba(1, 84, 116, 0.15);
    margin: 0 calc(-1 * max(12px, env(safe-area-inset-left))) 16px calc(-1 * max(12px, env(safe-area-inset-right)));
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 1200px;
    margin: 0 auto;
}

.logo-section,
.logo-section:visited {
    color: inherit;
    text-decoration: none;
    width: fit-content;
    margin: 0;
}

.header .logo-section:focus-visible {
    outline: 2px solid var(--white);
    outline-offset: 4px;
    border-radius: 4px;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.logo-img {
    height: 36px;
    width: auto;
    max-width: 45vw;
    object-fit: contain;
    display: block;
}

.logo-placeholder {
    width: 40px;
    height: 40px;
    flex: none;
    background-color: rgba(255, 255, 255, 0.2);
    border: 2px solid var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: bold;
    color: var(--white);
}

.header h1 {
    font-size: 18px;
    font-weight: 600;
    line-height: 1.2;
}

/* ============= MAIN CONTENT ============= */
.main-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ============= WORKING SECTION ============= */
.working-section {
    background: var(--white);
    padding: 16px;
    border-radius: var(--radius);
    box-shadow: 0 2px 8px rgba(1, 84, 116, 0.08);
    border-left: 4px solid var(--cerulean-bright);
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.dropdown-wrapper,
.swimlane-wrapper,
.goesto-wrapper,
.text-input-wrapper,
.images-wrapper {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

label {
    font-weight: 600;
    color: var(--text-dark);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dropdown,
.input-field {
    width: 100%;
    min-height: var(--tap);
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 16px; /* 16px stops iPhones from zooming in when a field is tapped */
    font-family: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background-color: var(--white);
    color: var(--text-light);
}

.dropdown:focus,
.input-field:focus {
    outline: none;
    border-color: var(--cerulean-bright);
    box-shadow: 0 0 0 3px rgba(12, 142, 215, 0.15);
}

.btn {
    min-height: var(--tap);
    padding: 10px 18px;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    font-size: 15px;
}

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

.btn:focus-visible,
.icon-btn:focus-visible,
.menu-btn:focus-visible,
.toggle-btn:focus-visible,
.drag-handle:focus-visible,
.row-menu-item:focus-visible,
.more-fields-btn:focus-visible {
    outline: 2px solid var(--cerulean-bright);
    outline-offset: 2px;
}

.btn-primary {
    background-color: var(--curious-blue);
    color: var(--white);
}

.btn-primary:active {
    background-color: var(--orient-dark);
}

.btn-secondary {
    background-color: var(--neptune-grey);
    color: var(--white);
}

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

.btn-small {
    min-height: 36px;
    padding: 6px 12px;
    font-size: 13px;
    background: var(--white);
    color: var(--orient-dark);
    border: 1px solid var(--border-color);
}

.btn-add {
    background-color: var(--cerulean-bright);
    color: var(--white);
    width: 100%;
    height: 48px;
    padding: 0 16px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 16px;
}

.btn-add:active {
    background-color: var(--orient-dark);
}

.plus-icon {
    display: block;
    font-size: 24px;
    line-height: 1;
}

/* Phones: optional fields fold away */
.more-fields-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    min-height: var(--tap);
    margin-top: 10px;
    padding: 8px 4px;
    background: none;
    border: none;
    border-top: 1px dashed var(--light-grey-blue);
    color: var(--curious-blue);
    font-size: 14px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}

.more-fields-chevron {
    display: inline-block;
    transition: transform 0.2s ease;
    transform: rotate(-90deg);
}

.working-section.show-more .more-fields-chevron {
    transform: rotate(0deg);
}

.optional-group {
    display: none;
    margin-top: 4px;
}

.working-section.show-more .optional-group {
    display: flex;
}

.optional-tag {
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: var(--light-greyish);
}

textarea.input-field {
    font-family: inherit;
    resize: vertical;
}

/* ============= MY PROCESSES (start screen) ============= */
.list-section {
    background: var(--white);
    padding: 16px 12px;
    border-radius: var(--radius);
    box-shadow: 0 2px 8px rgba(1, 84, 116, 0.08);
    border-left: 4px solid var(--cerulean-bright);
}

.list-page-header {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--light-grey-blue);
}

.list-page-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--orient-dark);
}

.btn-plus {
    font-size: 20px;
    line-height: 1;
    margin-right: 4px;
    vertical-align: -2px;
}

.list-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
}

.search-field {
    width: 100%;
}

.sort-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sort-wrapper label {
    margin: 0;
    white-space: nowrap;
}

.sort-wrapper .dropdown {
    flex: 1;
}

.process-list-header {
    display: none;
}

.process-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Phones / tablets: one card per process - name, a line with tasks + date, Edit button, ⋮ */
.process-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto 40px;
    grid-template-areas:
        "name actions menu"
        "meta actions menu";
    column-gap: 8px;
    row-gap: 2px;
    align-items: center;
    padding: 10px 4px 10px 12px;
    background: var(--white);
    border: 1px solid var(--light-grey-blue);
    border-left: 3px solid var(--cerulean-bright);
    border-radius: 6px;
    transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.process-row.just-added {
    background-color: #eef7fc;
    border-color: var(--cerulean-bright);
    box-shadow: 0 0 0 2px rgba(12, 142, 215, 0.25);
}

.process-row .pcol-name {
    grid-area: name;
    font-size: 16px;
    font-weight: 600;
    color: var(--orient-dark);
    overflow-wrap: anywhere;
}

.process-row .pcol-meta {
    grid-area: meta;
    font-size: 12px;
    color: var(--muted);
}

.process-row .pcol-tasks,
.process-row .pcol-updated {
    display: none;
}

.process-row .pcol-actions {
    grid-area: actions;
    display: flex;
    align-items: center;
    gap: 4px;
}

.process-row .pcol-menu {
    grid-area: menu;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-edit-process {
    white-space: nowrap;
    color: var(--cerulean-bright);
    border-color: var(--cerulean-bright);
}

.btn-edit-process:active {
    background-color: var(--light-grey-blue);
}

/* Icon buttons appear on wide screens only (phones use the ⋮ menu) */
.picon-btn {
    display: none;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--curious-blue);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
}

.picon-btn:active {
    background-color: var(--light-grey-blue);
}

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

.picon-btn:focus-visible {
    outline: 2px solid var(--cerulean-bright);
    outline-offset: 2px;
}

.process-list-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.5;
    padding: 4px 8px;
}

.process-list-message:not(:empty) {
    padding: 28px 8px;
}

.process-list-message.is-error {
    color: var(--danger-dark);
    font-weight: 600;
}

.list-section.is-empty .process-list-header {
    display: none !important;
}

/* ============= EDIT SCREEN HEADER: back link, name (click to rename), save status ============= */
.edit-header {
    background: var(--white);
    padding: 12px 16px 14px;
    border-radius: var(--radius);
    box-shadow: 0 2px 8px rgba(1, 84, 116, 0.08);
}

.edit-header .process-header {
    margin: 0;
    padding: 0;
    border: none;
}

.process-title-block {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    min-width: 0;
}

.back-link {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 4px 10px 4px 6px;
    margin-left: -6px;
    background: none;
    border: none;
    border-radius: 6px;
    color: var(--curious-blue);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.back-link:active {
    background-color: var(--light-grey-blue);
}

.back-link:disabled {
    opacity: 0.5;
    cursor: progress;
}

.back-link:focus-visible,
.rename-btn:focus-visible {
    outline: 2px solid var(--cerulean-bright);
    outline-offset: 2px;
}

.process-title-row {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.process-title-row .process-name {
    cursor: pointer;
}

.rename-btn {
    flex: none;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-radius: 50%;
    color: var(--light-greyish);
    font-size: 16px;
    cursor: pointer;
}

.rename-btn:active {
    background-color: var(--light-grey-blue);
    color: var(--cerulean-bright);
}

.save-status {
    font-size: 12px;
    font-weight: 600;
    color: var(--neptune-grey);
    min-height: 16px;
}

.save-status[data-state="saving"] {
    color: var(--muted);
}

.save-status[data-state="error"] {
    color: var(--danger-dark);
}

/* ============= TOAST ============= */
.toast {
    position: fixed;
    left: 50%;
    bottom: max(16px, env(safe-area-inset-bottom));
    z-index: 1100;
    max-width: calc(100vw - 32px);
    padding: 10px 18px;
    background: var(--orient-dark);
    color: var(--white);
    font-size: 14px;
    font-weight: 600;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(1, 84, 116, 0.3);
    transform: translate(-50%, 20px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* ============= RESULTS SECTION ============= */
.results-section {
    background: var(--white);
    padding: 16px 12px;
    border-radius: var(--radius);
    box-shadow: 0 2px 8px rgba(1, 84, 116, 0.08);
}

.process-header {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--light-grey-blue);
}

.process-name {
    font-size: 20px;
    font-weight: 700;
    color: var(--orient-dark);
    margin: 0;
    overflow-wrap: anywhere;
}

.process-actions {
    display: flex;
    gap: 10px;
}

.process-actions .btn {
    flex: 1;
}

.list-toolbar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
}

.list-hint {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.4;
}

.hint-grip {
    font-weight: 700;
    color: var(--orient-dark);
}

.list-toolbar-buttons {
    display: flex;
    gap: 8px;
}

.list-toolbar-buttons .btn {
    flex: 1;
}

/* ============= TASK LIST - phones and tablets: one card per task ============= */
/* Subtasks are indented cards (like Goblin Tools); number, type, swimlane and Goes To sit on a
   second line under the description. */
.task-list-container {
    min-width: 0;
}

.task-header {
    display: none;
}

.task-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.task-row {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr) auto 40px;
    grid-template-areas:
        "grip desc info menu"
        "grip meta meta menu";
    column-gap: 4px;
    row-gap: 2px;
    align-items: center;
    margin-left: calc(var(--level, 0) * var(--indent-step));
    padding: 6px 2px 6px 0;
    background-color: var(--white);
    border: 1px solid var(--light-grey-blue);
    border-left: 3px solid var(--light-grey-blue);
    border-radius: 6px;
    transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.task-row[data-depth="0"] {
    border-left-color: var(--cerulean-bright);
}

.col-grip {
    grid-area: grip;
    align-self: stretch;
    display: flex;
}

.drag-handle {
    flex: 1;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-radius: 4px;
    color: var(--light-greyish);
    cursor: grab;
    touch-action: none;           /* a finger on the grip drags the task instead of scrolling */
    -webkit-user-select: none;
    user-select: none;
}

.drag-handle svg {
    fill: currentColor;
    display: block;
}

.drag-handle:active {
    cursor: grabbing;
    color: var(--cerulean-bright);
}

.col-description {
    grid-area: desc;
    display: flex;
    align-items: flex-start;
    gap: 2px;
    min-width: 0;
    color: var(--text-light);
    font-size: 15px;
    line-height: 1.35;
}

.indent-spacer {
    flex: none;
    width: 0; /* cards are indented as a whole; the table indents inside this cell */
}

.toggle-btn,
.toggle-spacer {
    flex: none;
    width: 28px;
    height: 28px;
    margin: -4px 0;
}

.toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-radius: 50%;
    color: var(--orient-dark);
    cursor: pointer;
    transition: transform 0.15s ease, background-color 0.15s ease;
}

.toggle-btn:active {
    background-color: var(--light-grey-blue);
}

/* V = subtasks showing, > = hidden */
.task-row.is-collapsed .toggle-btn {
    transform: rotate(-90deg);
}

.desc-text {
    min-width: 0;
    overflow-wrap: anywhere;
    padding-top: 1px;
}

.hidden-count {
    display: inline-block;
    margin-left: 4px;
    padding: 0 6px;
    border-radius: 9px;
    background: var(--light-grey-blue);
    color: var(--orient-dark);
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    vertical-align: 1px;
}

.col-meta {
    grid-area: meta;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
    min-width: 0;
    padding-left: 30px; /* line up with the description text */
    font-size: 12px;
    color: var(--muted);
}

.meta-number {
    font-weight: 700;
    color: var(--curious-blue);
    font-variant-numeric: tabular-nums;
}

.meta-type .task-icon {
    width: 18px;
    height: 16px;
}

.meta-type .icon-box { width: 12px; height: 12px; }
.meta-type .icon-diamond { width: 10px; height: 10px; }
.meta-type .icon-pill { width: 16px; height: 10px; }

.meta-chip {
    max-width: 100%;
    padding: 1px 8px;
    border-radius: 10px;
    background: #f0f5f8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.meta-swimlane {
    color: var(--orient-dark);
}

.meta-goesto {
    color: var(--curious-blue);
    font-weight: 600;
}

.col-info {
    grid-area: info;
    display: flex;
    justify-content: center;
    align-items: center;
}

.col-info:empty {
    display: none;
}

.col-menu {
    grid-area: menu;
    align-self: stretch;
    display: flex;
    align-items: center;
    justify-content: center;
}

.menu-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-radius: 50%;
    color: var(--orient-dark);
    font-size: 22px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
}

.menu-btn:active,
.menu-btn[aria-expanded="true"] {
    background-color: var(--light-grey-blue);
}

/* Table-only cells are not used on cards */
.col-manipulation,
.col-number,
.col-swimlane,
.col-type,
.col-goesto {
    display: none;
}

/* Row that was just moved / indented keeps the focus */
.task-row.selected {
    background-color: #eef7fc;
    border-color: var(--cerulean-bright);
    box-shadow: 0 0 0 2px rgba(12, 142, 215, 0.25);
}

.col-number {
    font-weight: 600;
    color: var(--curious-blue);
    font-family: 'Arial Narrow', Arial, Helvetica, sans-serif;
    font-variant-numeric: tabular-nums;
    font-size: 12px;            /* script.js shrinks it further when a long number doesn't fit */
    white-space: nowrap;
    overflow: hidden;
}

.col-swimlane {
    font-size: 12px;
    color: var(--orient-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.col-goesto {
    font-size: 12px;
    color: var(--curious-blue);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.col-type {
    align-items: center;
    justify-content: center;
}

/* Task Type Icons */
.task-icon {
    width: 26px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-box {
    width: 18px;
    height: 18px;
    background-color: var(--cerulean-bright);
    border-radius: 3px;
}

.icon-diamond {
    width: 15px;
    height: 15px;
    background-color: var(--neptune-grey);
    transform: rotate(45deg);
    border-radius: 2px;
}

.icon-pill {
    width: 24px;
    height: 14px;
    background-color: var(--curious-blue);
    border-radius: 9px;
}

/* Hover action icons (desktop with a mouse only - see the media query at the end) */
.action-icons {
    display: none;
    gap: 2px;
    flex-wrap: nowrap;
}

.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px;
    width: 21px;
    height: 22px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

.icon-btn.move { color: var(--curious-blue); }
.icon-btn.indent { color: var(--neptune-grey); }
.icon-btn.delete { color: var(--danger); }
.icon-btn.edit { color: var(--cerulean-bright); }

/* ============= INFO ICON / TOOLTIP ============= */
.info-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1.5px solid var(--cerulean-bright);
    color: var(--cerulean-bright);
    font-size: 13px;
    font-weight: 700;
    font-style: italic;
    font-family: Georgia, 'Times New Roman', serif;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
}

.info-icon.has-images {
    border-style: double;
    border-width: 3px;
}

.info-tooltip {
    display: none;
    position: fixed;
    z-index: 900;
    max-width: min(500px, calc(100vw - 16px));
    padding: 10px 12px;
    background: var(--orient-dark);
    color: var(--white);
    font-size: 13px;
    line-height: 1.45;
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(1, 84, 116, 0.3);
    white-space: pre-wrap;
    word-break: break-word;
    pointer-events: none;
}

.info-tooltip.show {
    display: block;
}

.info-tooltip .tooltip-images {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.info-tooltip .tooltip-images:first-child {
    margin-top: 0;
}

.info-tooltip .tooltip-images img {
    width: 150px;
    max-width: 30vw;
    height: 110px;
    object-fit: cover;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.15);
}

.info-tooltip .tooltip-more {
    margin-top: 6px;
    font-size: 11px;
    opacity: 0.8;
}

/* ============= ROW ACTION MENU (⋮) ============= */
.row-menu {
    display: none;
    position: fixed;
    z-index: 980;
    min-width: 230px;
    max-width: calc(100vw - 16px);
    padding: 6px;
    background: var(--white);
    border: 1px solid var(--light-grey-blue);
    border-radius: 10px;
    box-shadow: 0 8px 28px rgba(1, 84, 116, 0.25);
}

.row-menu.show {
    display: block;
}

.row-menu-title {
    padding: 6px 10px 4px;
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.row-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: var(--tap);
    padding: 8px 10px;
    background: none;
    border: none;
    border-radius: 6px;
    color: var(--text-light);
    font-size: 15px;
    text-align: left;
    cursor: pointer;
}

.row-menu-item:active,
.row-menu-item:focus-visible {
    background: var(--light-grey-blue);
}

.row-menu-item:disabled {
    opacity: 0.35;
    cursor: default;
}

.row-menu-item.danger {
    color: var(--danger);
}

.row-menu-icon {
    width: 20px;
    text-align: center;
    font-weight: 700;
    color: var(--curious-blue);
}

.row-menu-item.danger .row-menu-icon {
    color: var(--danger);
}

/* ============= DRAG AND DROP ============= */
body.dragging,
body.dragging * {
    cursor: grabbing !important;
    -webkit-user-select: none;
    user-select: none;
}

.task-row.drag-source {
    opacity: 0.35;
    border-style: dashed;
}

.task-row.drag-hidden {
    display: none !important;
}

.task-row.drag-ghost {
    position: fixed;
    z-index: 950;
    margin: 0;
    pointer-events: none;
    opacity: 0.82;
    background: var(--white);
    border-color: var(--cerulean-bright);
    box-shadow: 0 10px 30px rgba(1, 84, 116, 0.3);
    transform: rotate(0.6deg);
}

.drag-ghost .action-icons {
    display: none !important;
}

.drag-ghost-badge {
    position: absolute;
    top: -9px;
    right: 10px;
    padding: 0 8px;
    border-radius: 9px;
    background: var(--orient-dark);
    color: var(--white);
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
}

.drop-line {
    display: none;
    position: fixed;
    z-index: 955; /* above the dragged card */
    height: 3px;
    border-radius: 2px;
    background: var(--cerulean-bright);
    pointer-events: none;
}

.drop-line::before {
    content: '';
    position: absolute;
    left: -5px;
    top: -4px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    border: 2px solid var(--cerulean-bright);
    background: var(--white);
    box-sizing: border-box;
}

.drop-label {
    display: none;
    position: fixed;
    z-index: 960;
    padding: 4px 10px;
    border-radius: 12px;
    background: var(--orient-dark);
    color: var(--white);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(1, 84, 116, 0.3);
}

.task-row.drop-into {
    background-color: #e3f2fb;
    border-color: var(--cerulean-bright);
    box-shadow: inset 0 0 0 2px var(--cerulean-bright);
}

/* ============= TASK IMAGES ============= */
.image-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.image-buttons .btn {
    flex: 1 1 auto;
}

.btn-image {
    background-color: var(--white);
    color: var(--curious-blue);
    border: 1px solid var(--curious-blue);
    padding: 10px 14px;
}

.btn-image:active {
    background-color: var(--curious-blue);
    color: var(--white);
}

.image-strip {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.image-strip:not(:empty) {
    margin-top: 12px;
}

.edit-form .image-strip:not(:empty) {
    margin-top: 0;
}

.image-thumb {
    position: relative;
    width: 84px;
    height: 64px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    background: var(--light-grey-blue);
}

.image-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.image-thumb-remove {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 50%;
    background: rgba(1, 84, 116, 0.85);
    color: var(--white);
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
}

.modal-content.modal-info {
    max-width: 900px;
}

.modal-content .info-modal-text {
    white-space: pre-wrap;
    word-break: break-word;
}

.info-modal-images {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.info-modal-images img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    border: 1px solid var(--light-grey-blue);
    align-self: center;
}

/* ============= EXPORT ============= */
.export-group {
    border: 1px solid var(--light-grey-blue);
    border-radius: 6px;
    padding: 12px 14px;
    margin-bottom: 12px;
}

.export-group h3 {
    color: var(--orient-dark);
    font-size: 15px;
    margin-bottom: 4px;
}

.modal-content .export-group p {
    font-size: 13px;
    margin-bottom: 10px;
    line-height: 1.4;
}

.export-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.export-buttons .btn {
    flex: 1 1 auto;
}

.modal-content .export-note {
    min-height: 18px;
    margin: 0;
    font-size: 13px;
    color: var(--curious-blue);
    font-weight: 600;
}

/* ============= PROCESS MAP PREVIEW ============= */
.modal-content.modal-wide {
    max-width: 1500px;
    display: flex;
    flex-direction: column;
    padding: 14px;
}

.process-map-toolbar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 10px;
}

.modal-content .process-map-toolbar h2 {
    margin: 0;
}

.process-map-preview {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    border: 1px solid var(--light-grey-blue);
    border-radius: 6px;
    background: var(--white);
    padding: 8px;
}

.process-map-preview svg {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
}

/* "Full size": the map keeps its real size and is scrolled / panned with a finger */
.process-map-preview.full-size svg {
    max-width: none;
    margin: 0;
}

.process-map-preview .pm-info-marker {
    cursor: pointer;
}

/* ============= MODALS ============= */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    inset: 0;
    padding: 8px;
    padding-top: max(8px, env(safe-area-inset-top));
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    background-color: rgba(1, 84, 116, 0.5);
    animation: fadeIn 0.3s ease;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    width: 100%;
    max-width: 500px;
    max-height: 100%;        /* tall dialogs (Edit Task) scroll instead of running off small screens */
    overflow-y: auto;
    overscroll-behavior: contain;
    background-color: var(--white);
    padding: 20px 16px;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(1, 84, 116, 0.2);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-content h2 {
    color: var(--orient-dark);
    margin-bottom: 16px;
    font-size: 20px;
}

.modal-content p {
    color: var(--text-light);
    margin-bottom: 16px;
    line-height: 1.6;
}

.modal-content .field-hint {
    font-size: 12px;
    margin: -4px 0 0;
    color: var(--muted);
    line-height: 1.4;
}

.modal-content .form-error {
    margin: 0;
    min-height: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--danger-dark);
}

#processModal .modal-content {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

#processModal .modal-content h2 {
    margin-bottom: 0;
}

#processModal .modal-buttons {
    margin-top: 0;
}

#processModal .form-error:empty {
    display: none;
}

.edit-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.edit-form label {
    margin-top: 8px;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.modal-buttons .btn {
    flex: 1;
}

/* ==========================================================================
   TABLET (600px and wider)
   ========================================================================== */
@media (min-width: 600px) {
    .container {
        padding-left: max(20px, env(safe-area-inset-left));
        padding-right: max(20px, env(safe-area-inset-right));
    }

    .header {
        padding: 20px 24px;
        margin-left: calc(-1 * max(20px, env(safe-area-inset-left)));
        margin-right: calc(-1 * max(20px, env(safe-area-inset-right)));
        margin-bottom: 24px;
    }

    .logo-section { gap: 18px; }
    .logo-img { height: 48px; max-width: 240px; }
    .header h1 { font-size: 24px; }

    .main-content { gap: 24px; }

    .working-section { padding: 22px; }

    .input-group {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: flex-end;
        gap: 14px;
    }

    .dropdown-wrapper { flex: 1 1 200px; }
    .swimlane-wrapper { flex: 1 1 160px; }
    .text-input-wrapper { flex: 999 1 240px; }
    .goesto-wrapper { flex: 1 1 260px; }
    .images-wrapper { flex: 0 0 auto; }

    .btn-add {
        width: 48px;
        height: 48px;
        padding: 0;
        border-radius: 50%;
        flex: none;
    }

    .add-label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    /* Enough room: optional fields always visible */
    .more-fields-btn { display: none; }
    .optional-group,
    .working-section .optional-group { display: flex; margin-top: 14px; }

    .results-section { padding: 22px; }

    .process-header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 16px;
        padding-bottom: 16px;
    }

    .process-name { font-size: 24px; }
    .process-actions .btn { flex: none; }

    .list-section { padding: 22px; }
    .edit-header { padding: 14px 22px 18px; margin-bottom: -10px; }
    .list-page-header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 16px;
        padding-bottom: 16px;
    }
    .list-page-title { font-size: 24px; }
    .list-controls {
        flex-direction: row;
        align-items: center;
        gap: 16px;
    }
    .search-wrapper { flex: 1 1 auto; max-width: 420px; }
    .sort-wrapper { flex: none; margin-left: auto; }
    .process-header { align-items: flex-end; }

    .list-toolbar {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 16px;
    }

    .list-toolbar-buttons .btn { flex: none; }

    :root { --indent-step: 22px; }

    .col-description { font-size: 15px; }

    .modal { padding: 20px; }
    .modal-content { padding: 26px; border-radius: 8px; }
    .modal-content.modal-wide { padding: 20px; max-height: 100%; }
    .process-map-toolbar {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        flex-wrap: wrap;
    }
    .export-buttons .btn { flex: none; }
    .image-buttons .btn { flex: none; }
}

/* ==========================================================================
   DESKTOP (900px and wider): the task list becomes a table with columns
   ========================================================================== */
@media (min-width: 900px) {
    .header {
        padding: 30px 24px;
        margin-bottom: 40px;
    }

    .logo-img { height: 60px; }
    .logo-placeholder { width: 60px; height: 60px; font-size: 24px; }
    .header h1 { font-size: 28px; }

    .main-content { gap: 40px; }

    .working-section,
    .results-section { padding: 30px; }

    .process-name { font-size: 28px; }

    .list-section { padding: 30px; }
    .edit-header { padding: 16px 30px 22px; margin-bottom: -24px; }
    .list-page-title { font-size: 28px; }

    /* My Processes becomes a table: Name | Tasks | Last updated | Actions */
    .process-list-header,
    .process-row {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 70px 190px 260px;
        grid-template-areas: none;
        column-gap: 12px;
        align-items: center;
    }

    .process-list-header {
        padding: 8px 12px;
        margin-bottom: 10px;
        background-color: var(--light-grey-blue);
        border-radius: 6px;
        font-weight: 600;
        color: var(--orient-dark);
        font-size: 13px;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .process-list { gap: 6px; }

    .process-row {
        padding: 6px 12px;
        border-left-width: 1px;
        border-left-color: var(--light-grey-blue);
    }

    .process-row .pcol-name,
    .process-row .pcol-meta,
    .process-row .pcol-actions,
    .process-row .pcol-menu { grid-area: auto; }
    .process-row .pcol-name { font-size: 15px; }
    .process-row .pcol-tasks,
    .process-row .pcol-updated { display: block; font-size: 13px; color: var(--text-light); }
    .process-row .pcol-tasks,
    .process-list-header .pcol-tasks { text-align: center; }
    .process-row .pcol-meta,
    .process-row .pcol-menu { display: none; }
    .process-row .pcol-actions { gap: 2px; }
    .picon-btn { display: flex; }

    :root {
        --indent-step: 16px;
        /* Grip | # | Swimlane | Type | Description | Goes To | Info | ⋮  (touch screens) */
        --task-grid: 30px 46px 120px 30px minmax(0, 1fr) 110px 30px 40px;
    }

    .task-header {
        display: grid;
        grid-template-columns: var(--task-grid);
        gap: 6px;
        padding: 8px 10px 8px 0;
        background-color: var(--light-grey-blue);
        border-radius: 6px;
        font-weight: 600;
        color: var(--orient-dark);
        font-size: 13px;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        margin-bottom: 10px;
    }

    .task-row {
        grid-template-columns: var(--task-grid);
        grid-template-areas: none;
        column-gap: 6px;
        margin-left: 0;
        padding: 4px 10px 4px 0;
        border-left-width: 1px;
        border-left-color: var(--light-grey-blue);
    }

    .task-row[data-depth="0"] {
        border-left-color: var(--light-grey-blue);
    }

    .task-row.selected,
    .task-row.drop-into {
        border-color: var(--cerulean-bright);
    }

    .task-row > *,
    .task-header > * {
        grid-area: auto;
    }

    .col-number,
    .col-swimlane,
    .col-goesto {
        display: block;
    }

    .col-type {
        display: flex;
    }

    .col-meta {
        display: none;
    }

    .col-description {
        font-size: 14px;
        align-items: center;
    }

    .indent-spacer {
        width: calc(var(--level, 0) * var(--indent-step));
    }

    .toggle-btn,
    .toggle-spacer {
        width: 22px;
        height: 22px;
        margin: 0 2px 0 0;
    }

    .desc-text { padding-top: 0; }

    .drag-handle { min-height: 32px; }

    .info-icon {
        width: 22px;
        height: 22px;
        font-size: 12px;
    }

    .col-info:empty {
        display: block;
    }

    .task-header .col-number,
    .task-header .col-swimlane,
    .task-header .col-goesto,
    .task-header .col-info,
    .task-header .col-type {
        font-size: 10px;
        letter-spacing: 0;
    }

    .task-header .col-description {
        font-size: 13px;
        padding-left: 24px;
    }

    .dropdown,
    .input-field {
        font-size: 15px;
    }
}

/* ==========================================================================
   MOUSE / TRACKPAD (a real hover exists)
   ========================================================================== */
@media (hover: hover) and (pointer: fine) {
    .btn-primary:hover:not(:disabled) {
        background-color: var(--orient-dark);
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(1, 84, 116, 0.2);
    }

    .btn-secondary:hover:not(:disabled) {
        background-color: var(--light-greyish);
        transform: translateY(-2px);
    }

    .btn-danger:hover { background-color: var(--danger-dark); }
    .btn-small:hover:not(:disabled) { background-color: var(--light-grey-blue); }
    .btn-add:hover { background-color: var(--orient-dark); }
    .btn-image:hover { background-color: var(--curious-blue); color: var(--white); }
    .image-thumb-remove:hover { background: var(--danger-dark); }
    .toggle-btn:hover { background-color: var(--light-grey-blue); }
    .menu-btn:hover { background-color: var(--light-grey-blue); }
    .row-menu-item:hover:not(:disabled) { background: var(--light-grey-blue); }
    .drag-handle:hover { color: var(--cerulean-bright); background-color: #f0f5f8; }
    .icon-btn:hover:not(:disabled) { background-color: var(--light-grey-blue); }
    .picon-btn:hover { background-color: var(--light-grey-blue); border-color: var(--light-greyish); }
    .btn-edit-process:hover { background-color: var(--cerulean-bright); color: var(--white); }
    .back-link:hover:not(:disabled) { background-color: var(--light-grey-blue); }
    .rename-btn:hover { background-color: var(--light-grey-blue); color: var(--cerulean-bright); }
    .process-title-row .process-name:hover { color: var(--cerulean-bright); }
    .header .logo-section:hover h1 { opacity: 0.85; }

    .process-row:hover {
        background-color: #f9fbfc;
        border-color: var(--cerulean-bright);
        box-shadow: 0 2px 8px rgba(12, 142, 215, 0.1);
    }

    .info-icon:hover {
        background-color: var(--cerulean-bright);
        color: var(--white);
    }

    .task-row:hover {
        background-color: #f9fbfc;
        border-color: var(--cerulean-bright);
        box-shadow: 0 2px 8px rgba(12, 142, 215, 0.1);
    }

    body.dragging .task-row:not(.drop-into):hover {
        background-color: var(--white);
        border-color: var(--light-grey-blue);
        box-shadow: none;
    }
}

/* Desktop with a mouse: action icons appear on hover in their own column, no ⋮ button */
@media (min-width: 900px) and (hover: hover) and (pointer: fine) {
    :root {
        /* Grip | Actions | # | Swimlane | Type | Description | Goes To | Info */
        --task-grid: 22px 138px 46px 120px 30px minmax(0, 1fr) 110px 26px;
    }

    .col-manipulation {
        display: flex;
        gap: 8px;
        align-items: center;
    }

    .col-menu {
        display: none;
    }

    .drag-handle { min-height: 28px; }

    .task-row:hover .action-icons,
    .task-row.selected .action-icons {
        display: flex;
    }

    body.dragging .task-row:hover .action-icons {
        display: none;
    }
}

/* ==========================================================================
   Phones turned sideways (short, wide screens): keep the header and the input
   area compact so the task list stays in view. Placed last so it wins over the
   width-based rules above.
   ========================================================================== */
@media (max-height: 500px) and (orientation: landscape) {
    .header {
        padding-top: max(8px, env(safe-area-inset-top));
        padding-bottom: 8px;
        margin-bottom: 12px;
    }

    .logo-img { height: 28px; }
    .logo-placeholder { width: 32px; height: 32px; font-size: 14px; }
    .header h1 { font-size: 18px; }

    .main-content { gap: 12px; }

    .working-section,
    .results-section { padding: 12px 16px; }

    .input-group { gap: 10px; }
    label { font-size: 12px; }

    /* Optional fields fold away, as on a phone held upright */
    .more-fields-btn { display: flex; }
    .working-section .optional-group { display: none; }
    .working-section.show-more .optional-group { display: flex; }

    .process-header { margin-bottom: 8px; padding-bottom: 8px; }
    .list-section { padding: 12px 16px; }
    .edit-header { padding: 8px 16px 10px; margin-bottom: 0; }
    .list-page-header { margin-bottom: 8px; padding-bottom: 8px; }
    .process-name { font-size: 20px; }

    .modal { padding: 6px; }
    .modal-content { padding: 14px 16px; }
    .modal-content h2 { margin-bottom: 8px; }
}

/* Honour "reduce motion" settings */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation: none !important;
        transition: none !important;
    }
}

/* ============= ADMIN SIGN-IN ============= */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.signout-btn {
    flex: none;
    min-height: 36px;
    padding: 6px 14px;
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 999px;
    background: transparent;
    color: var(--white);
    font-size: 14px;
    cursor: pointer;
}

.signout-btn[hidden] { display: none; }
.signout-btn:hover { background: rgba(255, 255, 255, 0.15); }
.signout-btn:focus-visible { outline: 2px solid var(--white); outline-offset: 2px; }

body.signin-open { overflow: hidden; }

.signin-screen {
    position: fixed;
    inset: 0;
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
    background: linear-gradient(135deg, var(--orient-dark) 0%, var(--curious-blue) 100%);
    overflow-y: auto;
}

.signin-card {
    width: 100%;
    max-width: 380px;
    margin: auto;
    padding: 24px 22px;
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(1, 84, 116, 0.35);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.signin-card h2 { color: var(--text-dark); font-size: 22px; }
.signin-card .signin-text { color: var(--text-light); font-size: 15px; line-height: 1.4; }
.signin-card label { font-size: 14px; color: var(--text-dark); }
.signin-card .input-field { width: 100%; font-size: 16px; min-height: var(--tap); }
.signin-card .signin-show { display: flex; align-items: center; gap: 8px; color: var(--muted); cursor: pointer; }
.signin-card .signin-show input { width: 18px; height: 18px; }
.signin-card .form-error:empty { display: none; }
.signin-card .signin-btn { width: 100%; min-height: var(--tap); justify-content: center; font-size: 16px; }
.signin-card .signin-note { color: var(--muted); font-size: 13px; text-align: center; }
