/* Dark-blue surfaces with orange memos, pink tools and a green vault. */
:root {
  --ui-page: #111c2b;
  --ui-sidebar: #0d1724;
  --ui-surface: #182638;
  --ui-raised: #22334a;
  --ui-border: #34465f;
  --ui-text: #e8edf5;
  --ui-muted: #bbc7d8;
  --ui-subtle: #98acc4;
  --ui-accent: var(--workspace-library);
  --ui-accent-hover: #f5c18e;
  --ui-accent-soft: #403125;
  --ui-highlight: var(--workspace-library);
  --ui-highlight-hover: #f5c18e;
  --ui-highlight-soft: #403125;
  --ui-on-accent: #0d1724;
  --ui-code: #0a1421;
  --workspace-library: #efa65e;
  --workspace-tools: #e5a0c5;
  --workspace-vault: #7ecba5;
  --bg: var(--ui-page);
  --panel: var(--ui-sidebar);
  --panel2: var(--ui-surface);
  --panel3: var(--ui-raised);
  --line: var(--ui-border);
  --text: var(--ui-text);
  --muted: var(--ui-muted);
  --accent: var(--ui-accent);
  --accent2: var(--ui-accent-hover);
  --danger: #da8991;
  --personal: #b3b8d1;
  --ok: #8bb99c;
  --warn: #d7b984;
  --shadow: 0 14px 40px rgba(0, 0, 0, .28)
}

* {
  box-sizing: border-box
}

html,
body {
  height: 100%;
  margin: 0;
  font-family: Segoe UI, Arial, sans-serif;
  background: var(--bg);
  color: var(--text)
}

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

button {
  cursor: pointer
}

.hidden {
  display: none !important
}

.muted {
  color: var(--muted)
}

.workspace-connection-error {
  color: var(--danger) !important
}

.settings-file .workspace-connection-error {
  color: #9b263f !important
}

.primary,
.secondary,
.danger,
.ghost,
.icon-btn {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  background: var(--panel2);
  color: var(--text)
}

.primary {
  background: var(--ui-highlight);
  border-color: var(--ui-highlight);
  color: var(--ui-on-accent)
}

.primary:hover {
  background: var(--ui-highlight-hover);
  border-color: var(--ui-highlight-hover)
}

.secondary:hover,
.ghost:hover,
.icon-btn:hover {
  background: var(--panel3)
}

.danger {
  color: #ff9ba5;
  border-color: #60343c;
  background: #21161a
}

.ghost {
  background: transparent
}

.icon-btn {
  padding: 9px 11px
}

/* LOCK */
#lock {
  position: fixed;
  inset: 0;
  z-index: 999;
  background:
    radial-gradient(circle at 50% 0%, #1d2a3e 0, #0d1016 52%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px
}

.lock-card {
  width: min(390px, 100%);
  background: rgba(20, 25, 35, .96);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 28px;
  box-shadow: var(--shadow);
  max-height: calc(100dvh - 32px);
  overflow-y: auto
}

.lock-logo {
  width: 58px;
  height: 58px;
  border-radius: 17px;
  margin: 0 auto 14px;
  background: linear-gradient(135deg, var(--accent), #344a8a);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 22px
}

.lock-sub {
  text-align: center;
  color: var(--muted);
  margin: 7px 0 22px
}

.pin-dots {
  display: flex;
  justify-content: center;
  gap: 13px;
  margin: 16px 0 24px
}

.dot {
  width: 15px;
  height: 15px;
  border: 2px solid #657389;
  border-radius: 50%
}

.dot.on {
  border-color: var(--accent);
  background: var(--accent)
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px
}

.key {
  height: 58px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel2);
  color: var(--text);
  font-size: 20px
}

.key:hover:not(:disabled) {
  background: #242d3d;
  border-color: #55647b
}

.key:disabled {
  cursor: default;
  opacity: .45
}

.lock-error {
  text-align: center;
  color: #ff8994;
  min-height: 40px;
  line-height: 20px;
  font-size: 13px;
  margin-top: 12px
}

/* APP CHROME */
#app {
  height: 100%;
  display: flex;
  flex-direction: column
}

.topbar {
  height: 70px;
  display: grid;
  grid-template-columns: 180px minmax(320px, 1fr) auto auto;
  gap: 18px;
  align-items: center;
  padding: 0 20px;
  background: #10141b;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50
}

.brand {
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap
}

.search {
  position: relative
}

.search input {
  width: 100%;
  background: #0a0e14;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 15px;
  color: var(--text);
  outline: none
}

.search input:focus {
  border-color: var(--accent)
}

.search-results {
  position: absolute;
  top: 50px;
  left: 0;
  right: 0;
  background: #111722;
  border: 1px solid var(--line);
  border-radius: 13px;
  box-shadow: var(--shadow);
  max-height: 430px;
  overflow: auto;
  z-index: 100
}

.search-result {
  padding: 11px 13px;
  border-bottom: 1px solid #232b39;
  cursor: pointer
}

.search-result:hover {
  background: #1d2532
}

.global-tabs {
  display: flex;
  gap: 6px
}

.global-tabs button {
  border: 1px solid var(--line);
  background: transparent;
  color: #cbd4e3;
  border-radius: 10px;
  padding: 10px 14px
}

.global-tabs button:hover {
  background: var(--panel2)
}

.global-tabs button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white
}

.main {
  display: flex;
  flex: 1;
  min-height: 0
}

.sidebar {
  width: 248px;
  flex: 0 0 248px;
  background: #10141b;
  border-right: 1px solid var(--line);
  padding: 15px;
  overflow: auto
}

.content {
  flex: 1;
  min-width: 0;
  overflow: auto;
  padding: 22px
}

.side-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px
}

.side-title strong {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: #c7d0de
}

.side-section {
  font-size: 11px;
  color: #718096;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin: 18px 8px 7px
}

.navrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 10px;
  border-radius: 9px;
  color: #c9d3e2;
  cursor: pointer;
  margin: 2px 0
}

.navrow:hover,
.navrow.active {
  background: #1e2633;
  color: white
}

.navrow span:last-child {
  color: #758299;
  font-size: 12px
}

/* HOME */
.home-shell {
  max-width: 1400px;
  margin: 0 auto
}

.hero {
  margin-bottom: 18px
}

.hero h1 {
  font-size: 27px;
  margin: 0 0 7px
}

.home-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr);
  gap: 18px
}

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

.card h3 {
  margin: 0 0 14px;
  font-size: 15px
}

.scratch {
  width: 100%;
  min-height: 260px;
  background: #0c1016;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  padding: 14px;
  resize: vertical;
  outline: none
}

.scratch:focus {
  border-color: var(--accent)
}

.home-item {
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 11px 12px;
  margin-bottom: 8px;
  cursor: pointer
}

.home-item:hover {
  background: var(--panel2)
}

/* COMMON LIST */
.workspace {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 16px;
  height: calc(100vh - 114px)
}

.list-pane,
.detail-pane {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 15px;
  overflow: auto
}

.list-header {
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 3;
  padding: 14px;
  border-bottom: 1px solid var(--line)
}

.list-header-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px
}

.list-filter {
  margin-top: 10px;
  width: 100%;
  background: #0c1016;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 9px;
  padding: 9px 10px;
  outline: none
}

.list-body {
  padding: 8px
}

.list-item {
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 12px;
  cursor: pointer;
  margin-bottom: 5px
}

.list-item:hover {
  background: #1a212d
}

.list-item.active {
  background: #202a39;
  border-color: #38465b
}

.list-item-title {
  font-weight: 700
}

.list-item-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 5px;
  display: flex;
  gap: 7px;
  flex-wrap: wrap
}

.badge {
  display: inline-flex;
  padding: 3px 7px;
  border-radius: 999px;
  background: #253149;
  color: #c5d6ff;
  font-size: 11px
}

.empty {
  padding: 42px;
  text-align: center;
  color: var(--muted)
}

.detail-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 15px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line)
}

.detail-title h2 {
  margin: 0 0 7px;
  font-size: 24px
}

.detail-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap
}

/* VIEW MODE */
.view-wrap {
  padding: 24px
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px
}

.info-box {
  background: #10151d;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px
}

.info-box .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #7f8ba0;
  margin-bottom: 6px
}

.info-box .value {
  font-size: 14px;
  word-break: break-word
}

.secret-line {
  display: flex;
  gap: 8px;
  align-items: center
}

.secret-mask {
  letter-spacing: .16em
}

.note-box {
  margin-top: 14px;
  background: #10151d;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 15px;
  white-space: pre-wrap;
  line-height: 1.55
}

.document-view {
  max-width: 960px;
  margin: 0 auto;
  padding: 34px 38px;
  line-height: 1.65
}

.document-view h1,
.document-view h2,
.document-view h3 {
  line-height: 1.25
}

.document-view pre {
  background: #090d12;
  border: 1px solid #273141;
  border-radius: 10px;
  padding: 13px;
  overflow: auto
}

.document-view table {
  border-collapse: collapse;
  width: 100%
}

.document-view td,
.document-view th {
  border: 1px solid #384254;
  padding: 8px
}

.command-view {
  max-width: 900px;
  margin: 0 auto;
  padding: 28px
}

.command-code {
  background: #090d12;
  border: 1px solid #2c3748;
  border-radius: 13px;
  padding: 18px;
  font-family: Consolas, monospace;
  font-size: 14px;
  white-space: pre-wrap;
  position: relative
}

.command-description {
  margin-top: 16px;
  white-space: pre-wrap;
  line-height: 1.6;
  color: #d7dfeb
}

.template-preview {
  max-width: 900px;
  margin: 0 auto;
  padding: 28px
}

.paper {
  background: #f6f7f9;
  color: #222;
  border-radius: 8px;
  min-height: 500px;
  padding: 42px 48px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .22);
  line-height: 1.55
}

.paper pre {
  white-space: pre-wrap;
  font-family: inherit
}

/* EDIT MODE */
.edit-shell {
  padding: 22px
}

.edit-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: #111824;
  border: 1px solid #33445f;
  border-radius: 12px;
  padding: 11px 13px;
  margin-bottom: 16px
}

.field {
  margin-bottom: 14px
}

.field label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px
}

.field input,
.field textarea,
.field select {
  width: 100%;
  background: #0c1016;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  padding: 10px 11px;
  outline: none
}

.field textarea {
  min-height: 110px;
  resize: vertical
}

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

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px
}

.toolbar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  background: #10151d;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  margin-bottom: 8px
}

.toolbar button {
  border: 1px solid var(--line);
  background: #171e29;
  color: var(--text);
  border-radius: 8px;
  padding: 7px 10px
}

.editor {
  min-height: 420px;
  background: #0c1016;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
  outline: none;
  line-height: 1.6
}

.editor:focus {
  border-color: var(--accent)
}

.editor pre {
  background: #080b10;
  border: 1px solid #242d3a;
  padding: 10px;
  border-radius: 8px
}

.kv-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
  margin-bottom: 8px
}

/* TEMPLATE LIB */
.template-library {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 13px;
  padding: 14px
}

.template-card {
  background: #111722;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 15px;
  cursor: pointer;
  min-height: 130px
}

.template-card:hover {
  border-color: #4a5e7e;
  background: #17202c
}

.template-card .type {
  font-size: 11px;
  text-transform: uppercase;
  color: #86a6ff;
  margin-bottom: 8px
}

/* MODAL */
.modal-wrap {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .66);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500
}

.modal {
  width: min(650px, 92vw);
  max-height: 88vh;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 21px;
  box-shadow: var(--shadow)
}

.modal h2 {
  margin-top: 0
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px
}

@media(max-width:1100px) {
  .topbar {
    grid-template-columns: 150px 1fr auto;
    height: auto;
    padding-top: 10px
  }

  .global-tabs {
    grid-column: 1/-1;
    order: 2;
    padding-bottom: 10px
  }

  .workspace {
    grid-template-columns: 300px 1fr;
    height: auto
  }

  .home-grid {
    grid-template-columns: 1fr
  }
}

@media(max-width:760px) {
  .sidebar {
    width: 200px;
    flex-basis: 200px
  }

  .workspace {
    grid-template-columns: 1fr
  }

  .list-pane {
    max-height: 380px
  }

  .info-grid,
  .form-grid {
    grid-template-columns: 1fr
  }
}

/* NESTED FOLDERS + DRAG & DROP */
.folder-drop-root {
  border: 1px dashed #344055;
  border-radius: 9px;
  padding: 8px 10px;
  margin: 5px 0 8px;
  color: #8e9bb0;
  font-size: 12px;
  transition: .15s
}

.folder-drop-root.drop-target,
.navrow.drop-target {
  background: #22314b;
  border-color: #5e88ff;
  color: #fff
}

.navrow.folder-row {
  border: 1px solid transparent;
  transition: .12s
}

.navrow.folder-row.dragging,
.list-item.dragging,
.template-card.dragging {
  opacity: .42
}

.folder-caret {
  display: inline-block;
  width: 16px;
  color: #718096
}

.folder-icon {
  margin-right: 6px
}

.drag-hint {
  font-size: 11px;
  color: #6f7d92;
  margin: 6px 7px 12px
}

/* RICH TEMPLATE EDITOR */
.template-editor-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 230px;
  gap: 14px
}

.template-editor-main {
  min-width: 0
}

.template-properties {
  background: #10151d;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px;
  height: max-content;
  position: sticky;
  top: 0
}

.template-properties h4 {
  margin: 0 0 12px
}

.toolbar.advanced {
  gap: 5px;
  align-items: center
}

.toolbar-group {
  display: flex;
  gap: 4px;
  align-items: center;
  padding-right: 6px;
  margin-right: 2px;
  border-right: 1px solid #2c3544
}

.toolbar-group:last-child {
  border-right: 0
}

.toolbar select {
  background: #171e29;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 8px
}

.toolbar input[type=color] {
  width: 34px;
  height: 32px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #171e29
}

.editor img {
  max-width: 100%;
  height: auto;
  border-radius: 5px;
  cursor: pointer;
  outline: 2px solid transparent
}

.editor img.editor-image-selected {
  outline-color: var(--accent)
}

.editor table {
  border-collapse: collapse;
  width: 100%;
  margin: 10px 0
}

.editor td,
.editor th {
  border: 1px solid #4b5668;
  padding: 7px;
  min-width: 45px
}

.editor .page-break {
  border-top: 2px dashed #66748b;
  margin: 22px 0;
  height: 2px;
  position: relative
}

.editor .page-break:after {
  content: "Saut de page";
  position: absolute;
  top: -11px;
  left: 50%;
  transform: translateX(-50%);
  background: #0c1016;
  color: #7d8aa0;
  padding: 0 8px;
  font-size: 10px
}

.paper img {
  max-width: 100%;
  height: auto
}

.paper table {
  border-collapse: collapse;
  width: 100%;
  margin: 10px 0
}

.paper td,
.paper th {
  border: 1px solid #777;
  padding: 7px
}

.paper .page-break {
  border-top: 1px dashed #aaa;
  margin: 26px 0;
  page-break-after: always
}

.template-help {
  font-size: 11px;
  color: #77869c;
  line-height: 1.45;
  margin-top: 10px
}

@media(max-width:1000px) {
  .template-editor-shell {
    grid-template-columns: 1fr
  }

  .template-properties {
    position: static
  }
}

/* V2.3 */
.tree-root-title {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border-radius: 9px;
  color: #d7e0ed;
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: 7px
}

.tree-root-title:hover,
.tree-root-title.active {
  background: #1e2633;
  border-color: #2d394a
}

.tree-root-title .tree-symbol {
  width: 18px;
  color: #8ca8dd
}

.tree-divider {
  height: 1px;
  background: var(--line);
  margin: 10px 2px 12px
}

.sidebar-empty {
  padding: 10px;
  color: #738198;
  font-size: 12px;
  line-height: 1.5
}

/* coffre plein espace */
.content.vault-content {
  overflow: hidden;
  padding: 16px
}

.content.vault-content .workspace {
  height: 100%;
  min-height: 0;
  grid-template-columns: minmax(300px, 32%) minmax(0, 1fr)
}

.content.vault-content .list-pane,
.content.vault-content .detail-pane {
  height: 100%;
  min-height: 0
}

.content.vault-content .list-pane {
  display: flex;
  flex-direction: column
}

.content.vault-content .list-body {
  flex: 1;
  min-height: 0;
  overflow: auto
}

.content.vault-content .detail-pane {
  display: flex;
  flex-direction: column;
  overflow: hidden
}

.content.vault-content #detailHost {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column
}

.vault-view {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr)
}

.vault-view-body {
  min-height: 0;
  padding: 18px 22px;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 12px;
  align-content: start;
  overflow: hidden
}

.vault-view-body .info-box {
  grid-column: span 6;
  min-width: 0
}

.vault-view-body .custom-grid {
  grid-column: span 12;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px
}

.vault-view-body .vault-notes {
  grid-column: span 12;
  min-height: 90px;
  max-height: 140px;
  overflow: auto;
  white-space: pre-wrap
}

.vault-view-tags {
  grid-column: span 12
}

.vault-edit {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden
}

.vault-edit-body {
  min-height: 0;
  padding: 14px 20px;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 10px 12px;
  align-content: start;
  overflow: hidden
}

.vault-edit-body .field {
  margin: 0;
  grid-column: span 6;
  min-width: 0
}

.vault-edit-body .field.third {
  grid-column: span 4
}

.vault-edit-body .field.wide {
  grid-column: span 12
}

.vault-edit-body .notes-field {
  grid-column: span 12
}

.vault-edit-body .notes-field textarea {
  min-height: 80px;
  max-height: 120px
}

.vault-edit-body .custom-editor {
  grid-column: span 12
}

.vault-edit-body #customFields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  max-height: 150px;
  overflow: auto
}

.vault-edit-body .kv-row {
  grid-template-columns: minmax(90px, .8fr) minmax(130px, 1.2fr) auto;
  margin: 0
}

.vault-edit-footer {
  padding: 11px 20px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  gap: 8px;
  flex-wrap: wrap
}

@media(max-width:1050px) {
  .vault-view-body .info-box {
    grid-column: span 12
  }

  .vault-edit-body .field,
  .vault-edit-body .field.third {
    grid-column: span 12
  }

  .vault-edit-body #customFields {
    grid-template-columns: 1fr
  }
}
