:root {
  /* tema scuro riposante ma leggibile */
  --bg: #191b21;
  --card: #232733;
  --card-2: #2a2f3d;
  --border: #3a4150;
  --text: #dde2ea;
  --muted: #949cab;
  --primary: #5b9dff;
  --primary-weak: #24344f;
  --request-bg: #69737f;    /* richiesta: chiaro, ben distinto */
  --discussion-bg: #1c2431; /* discussione: freddo scuro */
  --header-bg: #12141a;
  --header-text: #ffffff;
  --input-bg: rgba(42,47,59,0.9);
  --radius: 6px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
}
input, select, button, textarea { font-family: inherit; color: var(--text); }
::placeholder { color: #6f7787; }

/* sfondi input semitrasparenti (~90%): restano leggibili anche cambiando sfondo */
.ws__title, .ws__sel, .ws__date-in, .urlbtn__input,
.filters input, .filters select, .modal__input,
.field input, .recip-add__in, .dev-add__in {
  background: var(--input-bg);
}

.btn {
  border: 1px solid var(--border);
  background: var(--card-2);
  color: var(--text);
  border-radius: var(--radius);
  padding: 6px 12px;
  cursor: pointer;
  font-size: 12px;
}
.btn:hover { background: #333a4a; }
.btn--primary { background: var(--primary); color: #0f1b2e; border-color: var(--primary); font-weight: 600; }
.btn--primary:hover { filter: brightness(1.08); }
.btn--danger { color: #ff8a8a; }
.flash { animation: flash .6s ease; }
@keyframes flash { 0% { background: #2f6b4a; } 100% {} }

/* topbar */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--header-bg); color: var(--header-text); padding: 10px 18px; border-bottom: 1px solid var(--border);
}
.topbar__title { color: var(--header-text); }
.topbar__title { font-size: 16px; margin: 0; }
.topbar__user { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.topbar__user img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }
.topbar__icon { cursor: pointer; box-shadow: 0 0 0 2px transparent; transition: box-shadow .12s; }
.topbar__icon:hover { box-shadow: 0 0 0 2px var(--primary); }
.field.field--check { flex-direction: row; align-items: center; gap: 8px; }
.field.field--check input { flex: 0 0 auto; }

/* filters */
.filters {
  display: flex; gap: 8px; padding: 12px 18px; flex-wrap: wrap;
  background: var(--card); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 30;
}
.filters__q { flex: 1; min-width: 180px; }
.filters input, .filters select {
  padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 12px; background: var(--card-2);
}

/* list */
.list { padding: 12px 18px; }
.empty { color: var(--muted); text-align: center; padding: 24px; }
.rowwrap { margin-bottom: 8px; border-radius: var(--radius); }

/* riga aperta: bordo verde + più spazio sopra/sotto per staccarla dalle altre */
.rowwrap--open { box-shadow: 0 0 0 2px #35c26a; border-radius: var(--radius); margin: 50px 0; }

/* work settings = header di ogni riga. Stesso aspetto in lista e da aperto. */
.worksettings {
  display: grid;
  grid-template-columns: 50px 116px minmax(140px, 1fr) 84px 104px 66px 140px 104px;
  gap: 8px; align-items: center;
  padding: 8px 12px; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; font-size: 12px;
}
.worksettings:hover { background: var(--card-2); }
.worksettings--head {
  cursor: default; font-weight: bold; color: var(--text);
  background: var(--card-2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 12px; margin-bottom: 6px;
}
.worksettings--head:hover { background: var(--card-2); }

.ws__id { font-weight: bold; color: var(--primary); }
.ws__date { color: var(--muted); font-size: 11px; white-space: nowrap; }
.ws__title {
  min-width: 0; padding: 6px 8px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--card-2); font-size: 13px;
}
.ws__title:focus { outline: 1px solid var(--primary); }
.ws__meta { color: var(--text); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws__sel, .ws__date-in {
  min-width: 0; padding: 5px 4px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--card-2); font-size: 12px;
}
.ws__status { font-weight: 600; }
/* colore scadenza (colori priorità) in base ai giorni mancanti */
.dl--red { color: #ff6b6b; border-color: #ff6b6b; font-weight: 700; }
.dl--orange { color: #f0902c; border-color: #f0902c; font-weight: 700; }
.dl--yellow { color: #e6d98a; border-color: #e6d98a; font-weight: 600; }
.dl--green { color: #5bd07a; border-color: #5bd07a; font-weight: 600; }
.dl--blue { color: #6aa8ff; border-color: #6aa8ff; font-weight: 600; }

/* colore del testo della priorità in base al livello */
.pri--最高 { color: #ff6b6b; font-weight: 700; }
.pri--高 { color: #f0902c; font-weight: 700; }
.pri--中 { color: #e6d98a; font-weight: 600; }
.pri--低 { color: #5bd07a; font-weight: 600; }
.pri--最低 { color: #6aa8ff; font-weight: 600; }

/* status select colorato */
.status--確認中 { background: #3a3f4b; color: #cfd5df; }
.status--対応中 { background: #4a3f1e; color: #f0d68a; }
.status--確認待ち { background: #234655; color: #a9dcec; }
.status--完了 { background: #244d33; color: #93e2ac; }
.status--再確認依頼 { background: #4a2f1e; color: #f0b88a; }
.status--対応不可 { background: #4a2323; color: #f0a0a0; }

/* dettagli (rigaB + sezioni) sotto l'header */
.details { border: 1px solid var(--border); border-top: none; border-radius: 0 0 var(--radius) var(--radius); background: var(--card); }
.rowwrap--open .worksettings { border-radius: var(--radius) var(--radius) 0 0; border-bottom: none; }

/* header + rigaB fissi allo scroll quando aperto */
/* NB: nessun overflow:hidden sugli antenati, altrimenti position:sticky non aggancia */
.rowwrap--open .worksettings { position: sticky; top: 47px; z-index: 22; }
.rowwrap--open .rowB { position: sticky; top: 90px; z-index: 21; background: var(--card); }

/* rowB URLs — ognuno ~25% larghezza, testo editabile + apri + copia */
.rowB { padding: 8px 12px; border-bottom: 1px solid var(--border); }
.rowB__urls { display: flex; gap: 8px; width: 100%; }
.urlbtn { flex: 1 1 25%; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.urlbtn__label {
  font-size: 11px; color: var(--primary); font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.urlbtn__row {
  display: flex; align-items: stretch; min-width: 0;
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.urlbtn__input {
  flex: 1 1 auto; min-width: 0; border: none; background: var(--card-2);
  padding: 5px 8px; font-size: 11px; color: var(--text);
}
.urlbtn__input:focus { outline: 1px solid var(--primary); outline-offset: -1px; }
.urlbtn__open, .urlbtn__copy {
  flex: 0 0 auto; width: 26px; display: flex; align-items: center; justify-content: center;
  border: none; border-left: 1px solid var(--border); cursor: pointer;
}
.urlbtn__open, .urlbtn__copy { background: #2a2e3c; color: var(--muted); }
.urlbtn__open:hover, .urlbtn__copy:hover { color: var(--text); }
.urlbtn__ico { width: 14px; height: 14px; display: block; }

/* sections */
.section { padding: 12px; }
.section--request { background: var(--request-bg); }
.section--discussion { background: var(--discussion-bg); }
.section__label { margin: 0 0 8px; font-size: 12px; font-weight: 700; }
.section--request .section__label { color: #1b2330; }      /* sfondo chiaro → testo scuro */
.section--discussion .section__label { color: #cfd8e6; }   /* sfondo scuro → testo chiaro */

/* block: strip di stato a sinistra 20px squadrato, icona sovrapposta al bordo, data/ora a destra */
.block {
  position: relative; display: flex; align-items: flex-start; gap: 8px;
  background: var(--card); border: 1px solid var(--border);
  border-left: 20px solid var(--border); border-radius: 0;
  padding: 6px 8px 6px 14px; margin-bottom: 8px;
}
/* blocco di risposta: attaccato sotto al genitore, indentato */
.block--reply { margin-top: -8px; }

/* blocco che si sta trascinando: rettangolo tratteggiato attenuato */
.block--dragging { opacity: .35; outline: 2px dashed var(--primary); outline-offset: -2px; }
/* indicatore del punto di rilascio (linea verde in alto = "si inserisce qui") */
.block--dropinto { box-shadow: inset 0 4px 0 -1px #35c26a; }
/* durante il drag di un mio blocco, gli altrui sono visibilmente disabilitati */
.section__blocks--dragging .block:not(.block--mine) { opacity: .4; filter: grayscale(.85); }
/* ghost del drag (anteprima pulita al posto dell'immagine del blocco) */
.drag-ghost {
  position: fixed; top: -1000px; left: -1000px; padding: 6px 12px;
  background: var(--primary); color: #0f1b2e; border-radius: 6px;
  font-size: 12px; font-weight: 700; white-space: nowrap; box-shadow: 0 6px 20px rgba(0,0,0,.5);
}

.block__time {
  flex: 0 0 auto; width: 70px; display: flex; flex-direction: column; align-items: flex-end;
  font-size: 10px; line-height: 1.25; color: var(--muted); user-select: none; text-align: right;
  white-space: nowrap;
}
/* maniglia di trascinamento (sei puntini) sul bordo sinistro, sotto l'icona */
.block__handle {
  position: absolute; left: -20px; top: 12px; width: 20px; text-align: center;
  font-size: 26px; line-height: 1; color: #fff; cursor: grab; user-select: none;
}
.block:hover .block__handle { color: var(--primary); }
.block__handle:active { cursor: grabbing; }
/* icona utente sovrapposta al bordo sinistro, in alto */
.block__icon {
  position: absolute; top: -6px; left: -30px;
  width: 22px; height: 22px; border-radius: 50%; object-fit: cover;
  box-shadow: 0 0 0 2px var(--card); cursor: default;
}
/* tooltip dettagli utente */
.usertip {
  position: fixed; z-index: 220; display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: var(--card-2); border: 1px solid var(--border); border-radius: 6px; overflow: hidden;
  padding: 0 0 8px; font-size: 11px; box-shadow: 0 6px 20px rgba(0,0,0,.5); pointer-events: none;
}
.usertip__img { display: block; width: 200px; height: 200px; object-fit: cover; margin-bottom: 6px; }
.usertip strong { font-size: 12px; }
.usertip span { color: var(--muted); }
.block__body { flex: 1 1 auto; min-width: 0; min-height: 18px; line-height: 1.5; }
.block__body:focus { outline: 1px dashed var(--primary); }
.block__body:empty:before { content: attr(data-placeholder); color: var(--muted); pointer-events: none; }
.block__body a { color: var(--primary); }
.block__img { max-width: 320px; max-height: 240px; border-radius: 4px; display: block; }
.block__wrapped {
  flex: 1 1 auto; min-width: 0; position: relative; display: flex; align-items: flex-start; gap: 8px;
  border: 1px dashed var(--border); border-radius: 4px; padding: 6px 8px; background: var(--card-2);
}

/* menu contestuale (tasto destro) */
.ctxmenu {
  position: fixed; z-index: 200; min-width: 210px;
  background: var(--card-2); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,.5); padding: 5px; font-size: 12px;
}
.ctxmenu__gtitle { color: var(--muted); font-size: 10px; padding: 4px 8px; }
.ctxmenu__sep { height: 1px; background: var(--border); margin: 4px 2px; }
.ctxitem {
  display: flex; align-items: center; gap: 8px; width: 100%;
  border: none; background: transparent; color: var(--text);
  padding: 6px 8px; border-radius: 5px; cursor: pointer; text-align: left;
}
.ctxitem:hover { background: #333a4a; }
.ctxitem--danger { color: #ff9d9d; }
.ctxitem--danger:hover { background: #5a2b2b; }
.ctxdot { width: 12px; height: 12px; border-radius: 50%; flex: 0 0 auto; }
.ctxitem__txt { display: flex; flex-direction: column; line-height: 1.25; }
.ctxitem__txt small { color: var(--muted); font-size: 10px; }
.ctxitem__check { margin-left: auto; color: var(--primary); }

/* toolbar di selezione (link stile Propeller) */
.seltool {
  position: fixed; z-index: 210; display: flex; gap: 4px; align-items: center;
  background: var(--card-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 4px; box-shadow: 0 6px 20px rgba(0,0,0,.5);
}
.seltool__btn {
  border: none; background: transparent; color: var(--text);
  padding: 5px 8px; border-radius: 5px; cursor: pointer; font-size: 12px; white-space: nowrap;
}
.seltool__btn:hover { background: #333a4a; }
.seltool__btn--del { color: #ff9d9d; }
.seltool__input {
  border: 1px solid var(--border); background: var(--card); color: var(--text);
  border-radius: 5px; padding: 5px 8px; font-size: 12px; width: 200px;
}

/* addbar */
.addbar { display: flex; gap: 8px; margin-top: 4px; align-items: flex-start; }
.sendbox { margin-left: auto; position: relative; display: flex; gap: 0; }
.addbar__send { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.addbar__recip { border-top-left-radius: 0; border-bottom-left-radius: 0; border-left: 1px solid rgba(0,0,0,.25); padding: 6px 8px; }

/* pulldown destinatari */
.recip-panel {
  position: absolute; right: 0; bottom: calc(100% + 6px); z-index: 60; width: 280px;
  background: var(--card-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.5); max-height: 260px; overflow: auto;
}
.recip-item { display: flex; align-items: center; gap: 8px; padding: 4px 6px; font-size: 12px; border-radius: 5px; }
.recip-item:hover { background: #333a4a; }
.recip-item em { color: var(--muted); font-style: normal; }
.recip-item--group span { font-weight: 600; }
.recip-sep { height: 1px; background: var(--border); margin: 6px 2px; }
.recip-add { display: flex; gap: 6px; margin-top: 8px; }
.recip-add__in, .dev-add__in {
  flex: 1 1 auto; min-width: 0; padding: 6px 8px; font-size: 12px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--card);
}

/* anteprima email */
.mailprev__row { display: flex; gap: 8px; margin-bottom: 6px; font-size: 12px; }
.mailprev__k { flex: 0 0 44px; color: var(--muted); }
.mailprev__v { flex: 1 1 auto; word-break: break-all; }
.mailprev__body {
  background: var(--card-2); border: 1px solid var(--border); border-radius: 6px;
  padding: 10px; font-size: 12px; white-space: pre-wrap; word-break: break-word; max-height: 320px; overflow: auto;
}
.mailprev__note { color: var(--muted); font-size: 11px; margin: 8px 0 0; }

/* 表示設定 (appearance) */
.appr-modes { display: flex; gap: 14px; margin-bottom: 8px; align-items: center; }
.appr-modes input[type=color] { width: 48px; height: 26px; border: 1px solid var(--border); border-radius: 4px; background: none; cursor: pointer; padding: 0; }
.appr-mode { display: flex; align-items: center; gap: 6px; font-size: 12px; cursor: pointer; }
.appr-custom { display: flex; gap: 8px; justify-content: space-between; margin-bottom: 4px; }
.appr-swatch { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 1 1 0; min-width: 0; cursor: pointer; }
.appr-swatch span { font-size: 10px; color: var(--muted); text-align: center; line-height: 1.2; }
.appr-swatch input[type=color] { width: 100%; max-width: 56px; height: 28px; border: 1px solid var(--border); border-radius: 4px; background: none; cursor: pointer; padding: 0; }
.appr-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12px; margin: 4px 0; }
.appr-row select { flex: 0 0 auto; padding: 5px 8px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--input-bg); }
.appr-row input[type=color] { width: 44px; height: 26px; border: 1px solid var(--border); border-radius: 4px; background: none; cursor: pointer; }

/* lista developer (settings) */
.devlist { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.devlist__row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; background: var(--card-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 5px 8px; }

/* modal generico */
.modal-overlay, .auth-overlay, .cropper-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal, .auth-card, .cropper {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 20px;
  width: 380px; max-width: 92vw; box-shadow: 0 14px 50px rgba(0,0,0,.55);
}
.modal__title { margin: 0 0 10px; font-size: 15px; }
.modal__body { font-size: 13px; line-height: 1.6; margin-bottom: 16px; }
.modal__label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; }
.modal__input { width: 100%; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card-2); }
.modal__list { margin: 8px 0 0; padding-left: 18px; }
.modal__list li { color: #ff9d9d; }
.modal__actions { display: flex; justify-content: flex-end; gap: 8px; }

/* auth */
.auth-card h2 { margin: 0 0 4px; }
.auth-cardhead { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.auth-cardhead h2 { margin: 0; }
.auth-cardhead .auth-logout { flex: 0 0 auto; }
.auth-sub { color: var(--muted); margin: 0 0 14px; }
.auth-users { display: flex; flex-direction: column; gap: 8px; }
.auth-user { display: flex; align-items: center; gap: 10px; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card-2); cursor: pointer; text-align: left; color: var(--text); }
.auth-user:hover { background: #333a4a; }
.auth-user img { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.auth-user span { display: flex; flex-direction: column; }
.auth-user small { color: var(--muted); }
.auth-empty { color: var(--muted); }
.auth-card hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; font-size: 12px; }
.field input { padding: 7px 8px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--card-2); }
.req { color: #ff8a8a; }
.auth-error { color: #ff8a8a; margin: 4px 0; }
.auth-ok { color: #7fd88a; margin: 4px 0; }
.btn-link { display: block; width: 100%; margin-top: 8px; background: none; border: none; color: var(--muted); font-size: 12px; text-decoration: underline; cursor: pointer; text-align: center; }
.btn-link:hover { color: var(--text); }
.auth-login { width: 100%; }
.auth-actions, .auth-register { margin-top: 8px; }
.auth-register { width: 100%; }
.auth-actions { display: flex; justify-content: space-between; }
.reg-icon { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 14px; }
.reg-icon__img { width: 80px; height: 80px; border-radius: 12px; object-fit: cover; }

/* cropper */
.cropper h3 { margin: 0 0 12px; font-size: 14px; }
.cropper__stage { border: 2px solid var(--primary); border-radius: 8px; overflow: hidden; margin: 0 auto; touch-action: none; }
.cropper__canvas { display: block; cursor: grab; background: #111; }
.cropper__zoom { display: flex; align-items: center; gap: 8px; margin: 12px 0; font-size: 12px; }
.cropper__zoom input { flex: 1; }
.cropper__actions { display: flex; justify-content: space-between; }

@media (max-width: 860px) {
  .worksettings { grid-template-columns: 44px minmax(120px, 1fr) 90px; }
  .worksettings > :nth-child(2), .worksettings > :nth-child(4), .worksettings > :nth-child(5),
  .worksettings > :nth-child(6), .worksettings > :nth-child(7) { display: none; }
}
