:root {
  --ink: #1e1f24;
  --slate: #5b6470;
  --paper: #f7f4ef;
  --accent: #e05f2b;
  --accent-2: #2c7ea0;
  --card: #ffffff;
  --border: #e2dad0;
  --shadow: rgba(22, 24, 32, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Trebuchet MS", "Lucida Grande", "Noto Sans", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 20% 10%, #f8efe3, #f5f1ea 50%, #f1ece4 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

sup,
sub {
  font-size: 0.72em;
  line-height: 0;
  position: relative;
  vertical-align: baseline;
}

sup {
  top: -0.45em;
}

sub {
  bottom: -0.2em;
}

.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: linear-gradient(90deg, #f8ede0, #f4efe9);
  border-bottom: 1px solid var(--border);
 /* position: sticky; */
  top: 0;
  z-index: 10;
}

.nav-brand {
  font-weight: 700;
  letter-spacing: 0.04em;
}

.nav-links a {
  margin-left: 1rem;
  text-decoration: none;
  color: var(--ink);
  font-weight: 600;
}

.nav-auth {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  position: relative;
}

.nav-bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--ink);
  text-decoration: none;
  background: #f8f6f2;
}

.nav-bell-badge {
  position: absolute;
  top: -0.35rem;
  right: -0.35rem;
  min-width: 1rem;
  height: 1rem;
  padding: 0 0.22rem;
  border-radius: 999px;
  background: #d95f5f;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1rem;
  text-align: center;
}

.messages-popover {
  position: absolute;
  top: calc(100% + 0.45rem);
  right: 4.4rem;
  width: min(420px, calc(100vw - 2rem));
  max-height: min(70vh, 540px);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(20, 20, 30, 0.18);
  z-index: 1200;
  display: flex;
  flex-direction: column;
}

.messages-popover[hidden] {
  display: none;
}

.messages-popover-head,
.messages-popover-foot {
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.messages-popover-foot {
  border-bottom: none;
  border-top: 1px solid var(--border);
  justify-content: flex-end;
}

.messages-popover-body {
  overflow: auto;
  padding: 0.35rem 0.45rem;
}

.messages-popover-empty {
  padding: 1rem 0.55rem;
}

.messages-popover-item {
  border: 1px solid #e7dfd4;
  border-radius: 10px;
  padding: 0.55rem;
  margin: 0.4rem 0;
  background: #fffdfa;
}

.messages-popover-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.messages-popover-item-title {
  font-weight: 700;
}

.messages-popover-item-actions {
  display: flex;
  gap: 0.35rem;
  justify-content: flex-end;
  margin-top: 0.45rem;
}

.messages-workspace {
  padding: 0;
  overflow: hidden;
  height: calc(100dvh - 4.8rem);
  min-height: 0;
  margin-bottom: 0;
}

.card.messages-workspace {
  padding: 0;
}

.container.messages-page-container {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 0.35rem;
}

.container.messages-page-container .messages-workspace {
  margin-bottom: 0;
}

.messages-layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr) 320px;
  height: 100%;
  min-height: 0;
}

.messages-sidebar {
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, #fbf7f2 0%, #f7f1e8 100%);
  padding: 0.9rem 0.75rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.messages-sidebar-head {
  margin-bottom: 0.75rem;
  flex: 0 0 auto;
}

.messages-sidebar-head-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.messages-create-chat-btn {
  width: 2rem;
  height: 2rem;
  padding: 0;
}

.messages-sidebar-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.messages-sidebar-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding-right: 0.15rem;
}

.messages-view-tabs {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.55rem;
  flex-wrap: wrap;
}

.messages-compose-search {
  margin-bottom: 0.85rem;
  position: relative;
}

.messages-chat-filter-form {
  margin-bottom: 0.55rem;
}

.messages-chat-filter-form input {
  width: 100%;
}

.messages-text-input {
  width: 100%;
  height: 2.2rem;
  padding: 0.45rem 0.65rem;
  border: 1px solid #d9cfbf;
  border-radius: 10px;
  background: #fffdfa;
  box-shadow: none;
}

.messages-text-input:focus {
  outline: none;
  border-color: #2c7ea0;
  box-shadow: 0 0 0 2px rgba(44, 126, 160, 0.12);
}

.messages-input-anchor {
  position: relative;
  max-width: 340px;
}

.messages-input-anchor input {
  width: 100%;
}

.messages-compose-search label {
  font-size: 0.84rem;
  color: var(--slate);
  display: block;
  margin-bottom: 0.3rem;
}

.messages-compose-search input {
  width: 100%;
}

.messages-user-suggest {
  position: absolute;
  top: calc(100% + 0.25rem);
  left: 0;
  right: auto;
  width: 100%;
  min-width: 260px;
  max-width: 340px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(20, 20, 20, 0.12);
  z-index: 30;
  padding: 0.25rem;
}

.messages-user-suggest-item {
  display: flex;
  flex-direction: column;
  width: 100%;
  text-align: left;
  background: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.45rem 0.5rem;
  cursor: pointer;
}

.messages-user-suggest-item:hover {
  background: #f6f0e6;
}

.messages-user-suggest-item span {
  font-size: 0.8rem;
  color: var(--slate);
}

.messages-list-block {
  margin-top: 0.75rem;
}

.messages-list-block.is-chat-list {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.messages-list-title {
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--slate);
  margin-bottom: 0.4rem;
}

.messages-conversation-list,
.messages-user-list,
.messages-flat-list {
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
}

.messages-conversation-list {
  overflow: auto;
  max-height: none;
  flex: 1 1 auto;
  padding-right: 0.15rem;
}

.messages-conversation-row {
  position: relative;
}

.messages-list-divider {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0.45rem 0 0.15rem;
  color: var(--slate);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.messages-list-divider::before,
.messages-list-divider::after {
  content: "";
  height: 1px;
  background: #ddd2c2;
  flex: 1 1 auto;
}

.messages-room-delete-form {
  position: absolute;
  top: 0.55rem;
  right: 0.2rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  margin: 0;
  z-index: 3;
}

.messages-conversation-row.is-group:hover .messages-room-delete-form,
.messages-conversation-row.is-group:focus-within .messages-room-delete-form {
  opacity: 1;
  pointer-events: auto;
}

.messages-conversation-item,
.messages-user-item,
.messages-flat-item {
  border: 0;
  border-radius: 18px;
  background: transparent;
  padding: 0.6rem 0.45rem;
  text-decoration: none;
  color: inherit;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  width: 100%;
  position: relative;
}

.messages-conversation-item:hover,
.messages-user-item:hover {
  background: rgba(255, 255, 255, 0.75);
}

.messages-conversation-item.is-active {
  background: linear-gradient(180deg, rgba(255,255,255,0.9) 0%, rgba(248,250,255,0.95) 100%);
  box-shadow: 0 12px 24px rgba(33, 39, 54, 0.08);
  position: relative;
}

.messages-conversation-item.is-active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 4px;
  border-radius: 6px;
  background: #2c7ea0;
}

.messages-conversation-item.room-type-system {
  background: transparent;
}

.messages-conversation-item.room-type-group {
  background: transparent;
}

.messages-conversation-item.room-type-direct {
  background: transparent;
}

.messages-conversation-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 46px;
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  box-shadow: inset 0 -10px 20px rgba(0, 0, 0, 0.12);
}

.messages-conversation-avatar img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  border-radius: 50%;
}

.messages-conversation-avatar.room-type-direct {
  background: transparent;
  box-shadow: none;
}

.messages-conversation-avatar.room-type-group {
  background: linear-gradient(135deg, #58a9cf 0%, #2c7ea0 100%);
}

.messages-conversation-avatar.room-type-system {
  background: linear-gradient(135deg, #de7d7d 0%, #bf4a4a 100%);
}

.messages-conversation-main,
.messages-user-copy {
  min-width: 0;
  flex: 1 1 auto;
}

.messages-conversation-top {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: flex-start;
}

.messages-conversation-copy {
  min-width: 0;
  display: grid;
  gap: 0.1rem;
}

.messages-conversation-copy strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1rem;
}

.messages-conversation-badges {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  flex: 0 0 auto;
}

.messages-conversation-role {
  display: inline-block;
  font-size: 0.74rem;
  line-height: 1.1;
  color: var(--slate);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.messages-conversation-time {
  font-size: 0.78rem;
  color: #8a877f;
  white-space: nowrap;
  margin-top: 0.04rem;
}

.messages-conversation-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
  margin-top: 0.15rem;
}

.messages-conversation-preview {
  min-width: 0;
  flex: 1 1 auto;
  color: #797268;
  font-size: 0.88rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.messages-room-type {
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: #7f7161;
  background: #f5ede2;
  border: 1px solid #ead8bc;
  border-radius: 999px;
  padding: 0.12rem 0.34rem;
}

.messages-unread-pill {
  background: #d95f5f;
  color: #fff;
  border-radius: 999px;
  font-size: 0.65rem;
  line-height: 1;
  padding: 0.16rem 0.35rem;
  font-weight: 700;
}

.messages-mention-pill {
  background: #2c7ea0;
  color: #fff;
  border-radius: 999px;
  font-size: 0.65rem;
  line-height: 1;
  padding: 0.16rem 0.35rem;
  font-weight: 700;
}

.messages-thread {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: radial-gradient(circle at 20% 10%, #fffefb, #f9f3ea 70%, #f4ebde 100%);
}

.messages-rail {
  border-left: 1px solid var(--border);
  background: linear-gradient(180deg, #faf6f0 0%, #f5eee5 100%);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.messages-rail-head {
  padding: 0.7rem 0.75rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.messages-rail-title {
  margin: 0;
  font-size: 1rem;
}

.messages-rail-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  overflow: auto;
}

.messages-rail-foot {
  flex: 0 0 auto;
  padding: 0.65rem 0.75rem 0.8rem;
  border-top: 1px solid var(--border);
  background: rgba(250, 246, 240, 0.96);
  display: grid;
  gap: 0.4rem;
}

.messages-rail-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.75rem;
  font-size: 0.8rem;
}

.messages-rail-links a {
  color: var(--slate);
  text-decoration: none;
}

.messages-rail-links a:hover {
  color: var(--accent);
}

.messages-notice-item {
  display: grid;
  gap: 0.3rem;
  padding: 0.55rem 0.6rem;
  border-radius: 16px;
  border: 0;
  background: rgba(255, 255, 255, 0.7);
  color: inherit;
  text-decoration: none;
}

.messages-notice-item:hover {
  background: rgba(255, 255, 255, 0.95);
}

.messages-notice-item.is-unread {
  box-shadow: inset 3px 0 0 #d95f5f;
  background: linear-gradient(180deg, rgba(255,244,244,0.95) 0%, rgba(255,237,237,0.98) 100%);
}

.messages-notice-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.4rem;
}

.messages-notice-body {
  color: #584f43;
  font-size: 0.88rem;
}

.messages-notice-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.45rem;
  font-size: 0.74rem;
  color: var(--slate);
}

.messages-thread-head {
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
}

.messages-pinned-strip {
  padding: 0.55rem 0.85rem 0.3rem;
  border-bottom: 1px solid rgba(226, 218, 208, 0.8);
  background: rgba(255, 255, 255, 0.32);
}

.messages-pinned-list {
  display: flex;
  gap: 0.35rem;
  overflow: auto;
  padding-bottom: 0.2rem;
}

.messages-pinned-item {
  min-width: 180px;
  max-width: 240px;
  display: grid;
  gap: 0.15rem;
  padding: 0.38rem 0.48rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.82);
  text-decoration: none;
  color: inherit;
  border: 1px solid #e4d9cc;
}

.messages-thread-head-main {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  flex: 1 1 auto;
}

.messages-thread-title-row {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  min-width: 0;
  flex: 1 1 auto;
}

.messages-thread-title-row strong {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.messages-thread-kind {
  font-size: 0.8rem;
  color: var(--slate);
  white-space: nowrap;
}

.messages-thread-head-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 0 0 auto;
  min-width: 0;
}

.messages-thread-search-form {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  min-width: 0;
}

.messages-thread-search-input {
  width: min(180px, 18vw);
  min-width: 120px;
  height: 2rem;
  border-radius: 999px;
}

.messages-filter-icons {
  display: inline-flex;
  align-items: center;
  gap: 0.22rem;
}

.messages-filter-icons .icon-btn.icon-only {
  width: 2rem;
  height: 2rem;
  padding: 0;
}

.messages-filter-icons .icon-btn.icon-only.is-active {
  border-color: #2c7ea0;
  background: linear-gradient(180deg, #eff8fc 0%, #e5f1f8 100%);
  color: #2c7ea0;
}

.messages-mark-read-btn.is-active {
  border-color: #e7b87c;
  background: linear-gradient(180deg, #fff1db 0%, #ffe4bf 100%);
  color: #c56a1f;
}

.messages-mark-read-btn.is-idle,
.messages-mark-read-btn:disabled {
  border-color: #ddd8d0;
  background: #f4f1ec;
  color: #aaa39a;
  cursor: default;
  opacity: 1;
}

.messages-thread-body {
  flex: 1;
  overflow: auto;
  min-height: 0;
  padding: 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.messages-unread-separator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #b24242;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.messages-unread-separator::before,
.messages-unread-separator::after {
  content: "";
  height: 1px;
  background: #e0a8a8;
  flex: 1 1 auto;
}

.messages-bubble-row {
  display: flex;
  align-items: flex-end;
  gap: 0.55rem;
}

.messages-bubble-row.is-incoming {
  justify-content: flex-start;
}

.messages-bubble-row.is-outgoing {
  justify-content: flex-end;
}

.messages-thread-avatar {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  order: 1;
  border-radius: 50%;
  overflow: hidden;
  border: 0;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #9a6e3d;
}

.messages-thread-avatar.is-outgoing {
  order: 3;
}

.messages-thread-avatar img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.messages-bubble-row.is-selected .messages-bubble,
.messages-bubble-row:target .messages-bubble {
  box-shadow: 0 0 0 2px rgba(44, 126, 160, 0.38), 0 4px 14px rgba(0, 0, 0, 0.1);
}

.messages-bubble-cluster {
  position: relative;
  flex: 0 1 auto;
  max-width: min(76%, 760px);
  overflow: visible;
  order: 2;
  padding-right: 4.15rem;
}

.messages-bubble-row.is-outgoing .messages-bubble-cluster {
  padding-right: 0;
  padding-left: 4.15rem;
}

.messages-bubble {
  display: inline-block;
  max-width: 100%;
  width: fit-content;
  box-sizing: border-box;
  border: 1px solid #e3d7c8;
  border-radius: 12px;
  padding: 0.52rem 0.62rem;
  background: #fffdf8;
  position: relative;
}

.messages-bubble-tools {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  display: inline-flex;
  gap: 0.25rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.messages-bubble-tool {
  margin: 0;
}

.messages-bubble-row:hover .messages-bubble-tools,
.messages-bubble-row:focus-within .messages-bubble-tools {
  opacity: 1;
  pointer-events: auto;
}

.messages-reply-preview {
  display: grid;
  gap: 0.1rem;
  padding: 0.35rem 0.45rem;
  margin-bottom: 0.35rem;
  border-left: 3px solid #7fb0c7;
  background: rgba(123, 182, 211, 0.1);
  border-radius: 8px;
  color: #53606d;
  font-size: 0.84rem;
}

.messages-bubble-row.is-outgoing .messages-bubble {
  background: linear-gradient(180deg, #ffe9c8 0%, #ffdcb0 100%);
  border-color: #e3b780;
}

.messages-bubble-subject {
  font-weight: 700;
}

.messages-bubble-body {
  margin-top: 0.3rem;
  color: #4f4639;
}

.messages-bubble-meta {
  margin-top: 0.35rem;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: #6a6258;
  padding-right: 2rem;
}

.messages-message-no {
  color: #2c7ea0;
  text-decoration: none;
  font-weight: 700;
}

.messages-message-no:hover {
  text-decoration: underline;
}

.messages-bubble-author {
  color: #5b6470;
  font-weight: 600;
}

.messages-author-link {
  border: none;
  background: transparent;
  padding: 0;
  margin: 0;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
}

.messages-bubble-tools .icon-btn.icon-only {
  width: 30px;
  height: 30px;
  border-radius: 10px;
}

.messages-edit-history {
  margin-top: 0.3rem;
  font-size: 0.8rem;
  color: #6c655d;
}

.messages-edit-history summary {
  cursor: pointer;
  user-select: none;
}

.messages-edit-history-item {
  display: grid;
  gap: 0.1rem;
  padding: 0.25rem 0;
  border-top: 1px dashed #decdb8;
}

.messages-bubble-link {
  margin-top: 0.35rem;
}

.messages-attachment-card {
  margin-top: 0.45rem;
  display: grid;
  gap: 0.18rem;
  padding: 0.5rem 0.6rem;
  border-radius: 14px;
  border: 1px solid #dfd2bf;
  background: rgba(255, 255, 255, 0.72);
  color: inherit;
  text-decoration: none;
}

.messages-attachment-card:hover {
  background: rgba(255, 255, 255, 0.94);
}

.messages-attachment-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.messages-attachment-card span:last-child {
  color: var(--slate);
  font-size: 0.84rem;
}

.messages-reaction-rail {
  position: absolute;
  right: 0.35rem;
  top: 50%;
  transform: translateY(-50%);
  width: 3.4rem;
  height: 3.4rem;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.messages-bubble-row.is-outgoing .messages-reaction-rail {
  right: auto;
  left: 0.35rem;
}

.messages-reaction-orbit {
  position: relative;
  width: 3.4rem;
  height: 3.4rem;
}

.messages-reaction-summary {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: grid;
  gap: 0.18rem;
  justify-items: center;
  z-index: 1;
}

.messages-reaction-summary-item {
  margin: 0;
  display: flex;
}

.messages-reaction-summary-pill {
  min-width: 1.55rem;
  height: 1.05rem;
  padding: 0 0.22rem;
  border-radius: 999px;
  border: 0;
  background: rgba(255, 250, 243, 0.96);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.12rem;
  font-size: 0.62rem;
  line-height: 1;
  color: #6f5b42;
  box-shadow: 0 2px 8px rgba(76, 55, 33, 0.08);
  cursor: pointer;
}

.messages-reaction-summary-pill.is-active {
  background: #ebf6fb;
}

.messages-reaction-summary-emoji {
  font-size: 0.72rem;
  line-height: 1;
}

.messages-reaction-summary-count {
  font-weight: 700;
  line-height: 1;
}

.messages-reaction-trigger {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 1.95rem;
  height: 1.95rem;
  border: 0;
  background: rgba(248, 244, 237, 0.94);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #a8a19a;
  box-shadow: 0 2px 8px rgba(76, 55, 33, 0.08);
  padding: 0;
}

.messages-reaction-trigger.has-reactions {
  color: #6f5b42;
}

.messages-reaction-trigger .material-symbols-rounded {
  font-size: 0.95rem;
  line-height: 1;
}

.messages-reaction-orbit-item {
  position: absolute;
  top: 50%;
  left: 50%;
  padding: 0;
  margin: 0;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.16s ease, opacity 0.16s ease;
}

.messages-bubble-cluster:hover .messages-reaction-orbit-item,
.messages-bubble-cluster:focus-within .messages-reaction-orbit-item,
.messages-reaction-rail:hover .messages-reaction-orbit-item,
.messages-reaction-rail:focus-within .messages-reaction-orbit-item {
  opacity: 1;
  pointer-events: auto;
}

.messages-reaction-option {
  border: 0;
  background: #fffaf3;
  border-radius: 999px;
  width: 1.15rem;
  height: 1.15rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.7rem;
  line-height: 1;
  padding: 0;
}

.messages-reaction-option:hover {
  background: #fff;
}

.messages-reaction-option.is-active {
  background: #ebf6fb;
}

.messages-reaction-orbit-item.orbit-pos-1 {
  transform: translate(-50%, -50%) translate(0, -1.48rem);
}

.messages-reaction-orbit-item.orbit-pos-2 {
  transform: translate(-50%, -50%) translate(1.28rem, -0.8rem);
}

.messages-reaction-orbit-item.orbit-pos-3 {
  transform: translate(-50%, -50%) translate(1.28rem, 0.8rem);
}

.messages-reaction-orbit-item.orbit-pos-4 {
  transform: translate(-50%, -50%) translate(0, 1.48rem);
}

.messages-reaction-orbit-item.orbit-pos-5 {
  transform: translate(-50%, -50%) translate(-1.28rem, 0.8rem);
}

.messages-reaction-orbit-item.orbit-pos-6 {
  transform: translate(-50%, -50%) translate(-1.28rem, -0.8rem);
}

.messages-bubble-link a {
  color: #2c7ea0;
  font-weight: 600;
  text-decoration: none;
}

.messages-bubble-link a:hover {
  text-decoration: underline;
}

.messages-thread-compose {
  padding: 0.35rem 0.5rem;
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.55);
}

.messages-thread-compose form {
  margin: 0;
}

.messages-compose-attachment {
  margin-bottom: 0.35rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.45rem;
  padding: 0.32rem 0.42rem;
  border-radius: 10px;
  background: rgba(237, 246, 251, 0.86);
  border: 1px solid #cfe1ec;
}

.messages-compose-attachment-copy {
  min-width: 0;
  display: grid;
  gap: 0.08rem;
}

.messages-compose-attachment-copy span {
  font-size: 0.82rem;
  color: var(--slate);
}

.messages-compose-state {
  margin-bottom: 0.35rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.45rem;
  padding: 0.32rem 0.42rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid #ded3c4;
}

.messages-compose-state-copy {
  min-width: 0;
  display: grid;
  gap: 0.08rem;
}

.messages-compose-state-copy span {
  font-size: 0.82rem;
  color: var(--slate);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.messages-thread-compose .pure-group {
  margin-bottom: 0.3rem;
  border: 1px solid #d9cfbf;
  border-radius: 10px;
  overflow: hidden;
  background: #fffdfa;
}

.messages-thread-compose .pure-group input,
.messages-thread-compose .pure-group textarea {
  border: 0;
  box-shadow: none;
  padding: 0.3rem 0.42rem;
  font-size: 0.88rem;
  background: transparent;
}

.messages-thread-compose .pure-group input {
  border-bottom: 1px solid #e6dccd;
}

.messages-thread-compose .pure-group textarea {
  min-height: 58px;
  resize: vertical;
}

.messages-compose-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.messages-compose-entity-picker {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.messages-compose-submit {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.messages-entity-browser-head {
  display: grid;
  gap: 0.45rem;
  margin-bottom: 0.75rem;
}

.messages-entity-browser {
  display: grid;
  gap: 0.6rem;
  max-height: min(60vh, 560px);
  overflow: auto;
  padding-right: 0.1rem;
}

.messages-entity-tree {
  border: 1px solid #e1d7c9;
  border-radius: 12px;
  background: #fffdfa;
  overflow: hidden;
}

.messages-entity-tree-summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0.65rem;
  cursor: pointer;
}

.messages-entity-tree-summary::-webkit-details-marker {
  display: none;
}

.messages-entity-tree-title {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.messages-entity-tree-title .small-note {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.messages-entity-tree-children {
  padding: 0 0.55rem 0.55rem 2rem;
  display: grid;
  gap: 0.55rem;
}

.messages-entity-tree-group {
  display: grid;
  gap: 0.35rem;
}

.messages-entity-tree-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.65rem;
  border: 1px solid #e7dfd4;
  border-radius: 10px;
  padding: 0.45rem 0.55rem;
  background: #fff;
}

.messages-entity-tree-copy {
  min-width: 0;
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
}

.messages-entity-tree-copy > div {
  min-width: 0;
}

.messages-empty-thread {
  padding: 1.1rem;
}

.messages-members-panel {
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.45);
  flex: 0 0 auto;
  max-height: 150px;
  overflow: auto;
}

.messages-members-head {
  margin-bottom: 0.35rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.messages-members-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.messages-member-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid #dfd2bf;
  border-radius: 999px;
  padding: 0.16rem 0.36rem;
  background: #fffaf2;
}

.messages-member-chip.is-compact {
  gap: 0.22rem;
  padding: 0.08rem 0.28rem;
  font-size: 0.88rem;
}

.messages-member-chip.is-compact .messages-room-type {
  font-size: 0.62rem;
  padding: 0.08rem 0.32rem;
}

.messages-member-chip.is-compact .pure-button.button-sm {
  font-size: 0.72rem;
  padding: 0.1rem 0.35rem;
}

.messages-add-member-form {
  margin-top: 0.45rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.messages-add-member-form select {
  min-width: 280px;
}

.messages-add-member-list {
  display: grid;
  gap: 0.45rem;
}

.messages-add-member-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  border: 1px solid #e3d9cb;
  border-radius: 10px;
  padding: 0.45rem 0.55rem;
  background: #fffdfa;
  margin: 0;
}

.messages-add-member-row.is-static {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
}

.messages-room-settings-actions {
  margin-top: 0.75rem;
}

.messages-room-settings-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.messages-room-settings-note {
  margin-top: 0.75rem;
}

.messages-recipient-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.35rem 0 0.45rem;
}

.messages-recipient-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border: 1px solid #dbcfbf;
  border-radius: 999px;
  background: #fff9ef;
  padding: 0.14rem 0.34rem;
  font-size: 0.85rem;
}

.messages-recipient-chip-remove {
  border: none;
  background: transparent;
  line-height: 1;
  cursor: pointer;
  color: #9b6a49;
  font-size: 1rem;
}

.messages-row-actions {
  margin-top: 0.45rem;
  display: flex;
  gap: 0.4rem;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--slate);
}

.breadcrumb-inline {
  font-weight: 600;
}

.breadcrumb a {
  color: inherit;
  text-decoration: none;
  font-weight: 600;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.breadcrumb-sep {
  opacity: 0.6;
}

.breadcrumb-current {
  font-weight: 700;
  color: var(--ink);
}

.nav-user {
  font-weight: 600;
  color: var(--slate);
}

.nav-user a {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: inherit;
  text-decoration: none;
}

.nav-user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid #dbcdb8;
  background: #fff;
}

.auth-card {
  max-width: 420px;
  margin: 4rem auto;
}

.auth-error {
  margin-bottom: 1rem;
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  background: #fbe3d9;
  color: var(--accent);
  font-weight: 600;
}

.auth-actions {
  margin-top: 0.75rem;
  text-align: right;
}

.table-wrap {
  overflow-x: auto;
}

.inline-form {
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
}

.button-warn {
  background: #f0b429;
  color: #1f1f1f;
}

.button-danger {
  background: #d64541;
  color: #fff;
}

.muted {
  color: var(--slate);
  font-size: 0.9rem;
}

.toast {
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  font-weight: 700;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.toast-success {
  background: #e7f5ea;
  color: #2f6d3a;
  border: 1px solid #cfe8d5;
}

.toast-error {
  background: #fde6e0;
  color: #a23b2a;
  border: 1px solid #f3c9bf;
}

.toast-inline {
  margin-top: 0.5rem;
}

.toast-close {
  background: transparent;
  border: none;
  cursor: pointer;
  font-weight: 700;
  font-size: 1.1rem;
  line-height: 1;
}

.row-banned {
  background: #fde6e0;
}

.status-dot {
  width: 12px;
  height: 12px;
  min-width: 12px;
  min-height: 12px;
  aspect-ratio: 1 / 1;
  flex: 0 0 12px;
  border-radius: 999px;
  display: inline-block;
  vertical-align: middle;
  background: radial-gradient(circle at 30% 30%, #ffffff, #c4c4c4 60%);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.15);
}

.status-dot.online {
  background: radial-gradient(circle at 30% 30%, #eafff2, #2ecc71 60%);
}

.status-dot.offline {
  background: radial-gradient(circle at 30% 30%, #ffecec, #d64541 60%);
}

.reset-btn {
  position: relative;
}

.reset-form {
  position: relative;
}

.reset-btn .alert-dot {
  position: absolute;
  right: -4px;
  top: -4px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #e05f2b;
  border: 2px solid #fff;
}

.reset-toast {
  position: absolute;
  left: 3rem;
  top: -0.5rem;
  min-width: 220px;
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  background: #fff7e6;
  border: 2px solid #f1d19c;
  color: #7a4b00;
  font-weight: 700;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  z-index: 5;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.08);
}

.reset-close {
  background: transparent;
  border: none;
  cursor: pointer;
  font-weight: 700;
}

.admin-actions {
  display: flex;
  gap: 0.5rem;
}

.tab-row {
  display: inline-flex;
  gap: 0.5rem;
  margin: 0.5rem 0 1rem;
  flex-wrap: wrap;
}

.tab-btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--slate);
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
}

.tab-btn.is-active {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

.kanban-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.kanban-column {
  background: #f8f4ee;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem;
}

.kanban-column[data-status="init"] {
  background: #f4f2ef;
}

.kanban-column[data-status="in_progress"] {
  background: #fff3e2;
  border-color: #f0d2a7;
}

.kanban-column[data-status="done"] {
  background: #eaf6ef;
  border-color: #cbe4d6;
}

.kanban-column[data-status="failed"] {
  background: #fdecea;
  border-color: #f5c9c4;
}

.kanban-column.is-drop-target {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px rgba(224, 95, 43, 0.25);
}

.kanban-title {
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.kanban-list {
  display: grid;
  gap: 0.5rem;
}

.kanban-card {
  width: 100%;
  text-align: left;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem 0.7rem;
  box-shadow: 0 6px 14px var(--shadow);
  cursor: pointer;
}

.kanban-card.is-dragging {
  opacity: 0.6;
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.2);
}

.kanban-card-title {
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.kanban-card-meta {
  font-size: 0.85rem;
  color: var(--slate);
}

.kanban-card-progress {
  margin-top: 0.4rem;
  font-weight: 700;
  color: var(--accent);
}

.task-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.5rem 1rem;
}

.task-due {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  position: relative;
}

.task-due-icon {
  font-size: 16px;
  color: #9a9a96;
}

.calendar-actions {
  position: relative;
  margin-top: 0.25rem;
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.calendar-menu {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.5rem;
  display: none;
  gap: 0.5rem;
  flex-direction: column;
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.12);
  z-index: 20;
  min-width: 180px;
}

.calendar-menu.is-open {
  display: flex;
}

.collapsible {
  display: none;
  margin-top: 0.75rem;
}

.collapsible.is-open {
  display: block;
}

.task-entity-form {
  margin-top: 0.5rem;
  padding: 0.75rem;
  border-radius: 12px;
  background: #fff8f1;
  border: 1px solid #f0d7bf;
}

.task-entity-picker {
  margin-top: 1rem;
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.task-entity-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem;
  background: #fffaf4;
  display: grid;
  gap: 0.5rem;
}

.task-entity-title {
  font-weight: 700;
}

.task-entity-steps {
  display: grid;
  gap: 0.35rem;
}

.task-entity-steps .pure-checkbox.is-attached {
  opacity: 0.6;
}

.task-entity-steps .pure-checkbox.is-attached input {
  accent-color: #7b8a8b;
}

.is-hidden {
  display: none;
}

.task-entity-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.4rem 1rem;
  padding: 0.4rem 0;
  border-bottom: 1px dashed var(--border);
}

.entity-type {
  margin-left: 0.4rem;
  font-size: 0.75rem;
  color: var(--slate);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
  width: 100%;
}

.container.wide {
  max-width: 1600px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.25rem;
  box-shadow: 0 12px 26px var(--shadow);
  margin-bottom: 1.5rem;
}

.card-title {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: nowrap;
  min-width: 0;
}

.title-row .card-title {
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-hero {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.profile-hero-main {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.profile-hero-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.profile-name {
  font-size: 1.3rem;
  margin-bottom: 0.35rem;
}

.profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 22px;
  border: 1px solid #decfb9;
  background: #fff;
}

.profile-avatar-lg {
  width: 110px;
  height: 110px;
  border-radius: 28px;
  border: 0;
  background: transparent;
}

.profile-avatar-config {
  display: grid;
  gap: 0.75rem;
}

.profile-settings-block {
  margin-top: 1rem;
  padding: 0.9rem 1rem;
  border-radius: 16px;
  border: 1px solid #e4d7c7;
  background: linear-gradient(180deg, #fffdf8 0%, #f8f2e9 100%);
}

.profile-settings-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.7rem;
}

.profile-avatar-config-top {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.profile-avatar-config-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem 0.9rem;
}

.profile-avatar-section {
  display: grid;
  gap: 0.35rem;
}

.profile-avatar-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.profile-avatar-chip {
  border: 1px solid #ddd1c1;
  background: #fffaf3;
  color: #51493f;
  border-radius: 999px;
  padding: 0.28rem 0.55rem;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
  font-size: 0.84rem;
}

.profile-avatar-chip.is-active {
  border-color: #2c7ea0;
  background: #ebf6fb;
  color: #2c7ea0;
}

.profile-avatar-chip .material-symbols-rounded {
  font-size: 1rem;
}

.profile-avatar-swatch {
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.profile-avatar-swatch.palette-amber { background: #f0ba63; }
.profile-avatar-swatch.palette-ocean { background: #58a9cf; }
.profile-avatar-swatch.palette-rose { background: #d45771; }
.profile-avatar-swatch.palette-mint { background: #37966b; }
.profile-avatar-swatch.palette-violet { background: #6b5db7; }
.profile-avatar-swatch.skin-fair { background: #f2d3b1; }
.profile-avatar-swatch.skin-warm { background: #e8b37e; }
.profile-avatar-swatch.skin-olive { background: #c68655; }
.profile-avatar-swatch.skin-brown { background: #8d5524; }
.profile-avatar-swatch.skin-deep { background: #5c3836; }


.grid-two {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.chart-grid {
  grid-template-columns: repeat(2, minmax(260px, 1fr));
}

@media (max-width: 900px) {
  .chart-grid {
    grid-template-columns: 1fr;
  }

  .profile-avatar-config-grid {
    grid-template-columns: 1fr;
  }
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: #fbe3d9;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.75rem;
}

.badge.imported {
  background: #dfe8f4;
  color: #2f496f;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.01em;
  background: #efe8dd;
  color: #6b6156;
}

.status-pill.status-done {
  background: #dcefe4;
  color: #1f7a4f;
}

.status-pill.status-in_progress {
  background: #f7ead7;
  color: #8a5a1f;
}

.status-pill.status-not_started {
  background: #f4dad7;
  color: #9e2b2b;
}

.icon-btn {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  font-weight: 600;
  color: #2c2c28;
}

.icon-btn.warn {
  color: #8a5a1f;
  border-color: #e7c59a;
}

.icon-btn.danger {
  color: #9f2d2d;
  border-color: #e2b3ad;
}

.recipes-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.recipes-header-left {
  display: grid;
  gap: 0.5rem;
}

.recipes-import-file {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.recipe-import-text {
  border-top: 1px dashed #e2d7c6;
  padding-top: 0.75rem;
}

.recipes-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.recipes-actions form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.recipes-list-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.recipe-import-text {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.75rem;
  margin-bottom: 0.75rem;
  max-width: 520px;
}

.recipe-import-text textarea {
  width: 100%;
  min-height: 140px;
  padding: 0.6rem 0.75rem;
  border-radius: 12px;
  border: 1px solid #d8d2c5;
  background: #fff;
  font-size: 0.9rem;
  resize: vertical;
}

.recipe-search {
  min-width: 220px;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  border: 1px solid #d8d2c5;
  background: #fff;
  font-size: 0.9rem;
}

.recipe-card-grid {
  column-gap: 16px;
  column-count: 2;
  margin-top: 0.75rem;
}

@media (min-width: 900px) {
  .recipe-card-grid {
    column-count: 3;
  }
}

@media (min-width: 1200px) {
  .recipe-card-grid {
    column-count: 4;
  }
}

@media (min-width: 1500px) {
  .recipe-card-grid {
    column-count: 5;
  }
}

.recipe-card {
  background: #f3efe2;
  border: 1px solid #e4ded2;
  border-radius: 22px;
  padding: 16px 16px 14px;
  display: grid;
  gap: 10px;
  min-height: 200px;
  break-inside: avoid;
  margin: 0 0 16px;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.recipe-card:hover {
  background: #ffffff;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.12);
}

.recipe-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.recipe-card-header h3 {
  margin: 0;
  font-size: 1.4rem;
}

.recipe-desc {
  color: #4b4b46;
  font-size: 0.9rem;
}

.recipe-components {
  display: grid;
  gap: 6px;
  align-content: start;
  width: fit-content;
  font-weight: 600;
  color: #2c2c28;
}

.recipe-comp-line {
  display: grid;
  grid-template-columns: 1fr auto;
  column-gap: 12px;
  font-size: 0.9rem;
  font-weight: 500;
  align-items: baseline;
}

.recipe-comp-name {
  display: flex;
  align-items: baseline;
}

.recipe-comp-name sub,
.recipe-comp-name sup {
  font-size: 0.75em;
  line-height: 0;
  position: relative;
  vertical-align: baseline;
}

.recipe-comp-name sup {
  top: -0.45em;
}

.recipe-comp-name sub {
  top: 0.2em;
}

.recipe-comp-name::after {
  content: "";
  flex: 1 1 auto;
  border-bottom: 1px dotted rgba(44, 44, 40, 0.35);
  transform: translateY(-2px);
  margin-left: 8px;
}

.recipe-comp-qty {
  text-align: left;
  min-width: 48px;
}

.recipe-comp-more {
  font-size: 0.8rem;
  color: #6b6355;
}

.recipe-card-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.icon-btn.icon-only {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  font-size: 0.8rem;
}

.material-symbols-rounded {
  font-size: 20px;
  line-height: 1;
}

.inline-form {
  margin: 0;
}

.recipe-edit-table input {
  width: 100%;
  padding: 0.35rem 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
}

.recipe-edit-actions {
  margin-top: 0.6rem;
  display: flex;
  justify-content: flex-start;
}

.recipe-select-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.recipe-select-card {
  background: #f3efe2;
  border: 1px solid #e4ded2;
  border-radius: 16px;
  padding: 12px;
  text-align: left;
  width: 100%;
  display: grid;
  gap: 8px;
  cursor: pointer;
  position: relative;
  transition: background 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.recipe-select-card input[type="checkbox"] {
  display: none;
}

.recipe-select-card.active {
  background: #ffffff;
  border-color: #2f6b4f;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.12);
}

.recipe-select-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.recipe-select-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
}

.recipe-select-desc {
  font-size: 0.75rem;
  font-weight: 400;
  color: #4b4b46;
  line-height: 1.3;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
  width: 100%;
}

.card-header .card-title {
  margin: 0;
}


.card-title + .small-note {
  display: block;
  margin-top: 0.35rem;
}

.card-header.card-header-main {
  width: 100%;
}

.card-header.card-header-main .section-actions {
  margin-left: auto;
}

.status-pill.status-archived {
  background: #e2e2e2;
  color: #5a5a52;
}

.section-links {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.section-list {
  display: grid;
  gap: 0.75rem;
}

.section-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  flex-wrap: wrap;
}

.section-row > .section-actions {
  margin-left: auto;
}

.qualification-compact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.6rem;
}

.qualification-compact-card {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  padding: 0.55rem 0.65rem;
  display: grid;
  gap: 0.35rem;
}

.qualification-compact-card.is-locked {
  opacity: 0.78;
}

.qualification-compact-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
}

.qualification-compact-name {
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.3;
}

.qualification-compact-summary {
  display: grid;
  gap: 0.2rem;
}

.assignment-form {
  margin: 0.15rem 0 0.3rem;
}

.assignment-form select {
  min-width: 200px;
}

.qualification-compact-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.45rem;
}

.section-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.section-title {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 600;
}

.section-title.is-disabled {
  color: var(--slate);
  text-decoration: none;
  cursor: not-allowed;
}

.card-lock-overlay {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: rgba(255, 255, 255, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: all;
}

.card-lock-overlay span {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #6a665f;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  border: 1px solid #d1c7b9;
  background: rgba(248, 243, 234, 0.95);
}

.section-title:hover {
  color: var(--accent-dark);
}

.link-muted {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  color: #6f6b63;
  font: inherit;
  cursor: pointer;
  border-bottom: 1px dotted #b7b1a7;
}

.link-muted:hover {
  color: #4f4b45;
  border-bottom-color: #8f877b;
}

.collapsible-toggle {
  display: inline-block;
  margin-top: 0.75rem;
}

.task-entity-form .link-muted {
  display: inline-block;
  margin: 0.5rem 0 0.75rem;
}

.task-entity-form .collapsible.is-open {
  margin-top: 0.5rem;
}

.attach-entities-btn {
  margin-top: 0.75rem;
}

.field-toolbar {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  flex-wrap: wrap;
  margin: 0.5rem 0 1rem;
}

.field-toolbar label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
  color: var(--ink);
}

.param-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.param-search label {
  display: block;
  font-size: 0.85rem;
  color: var(--ink);
  margin-bottom: 0.25rem;
}

.filter-block {
  display: grid;
  gap: 0.75rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  margin-bottom: 1rem;
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.filter-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
  min-width: 60px;
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.filter-chip {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
  font-size: 0.8rem;
  cursor: pointer;
}

.filter-chip.active {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.filter-chip.kind-input {
  color: #255b8a;
  border-color: rgba(37, 91, 138, 0.4);
}

.filter-chip.kind-output {
  color: #7a3d2a;
  border-color: rgba(122, 61, 42, 0.4);
}

.filter-chip.type-number {
  color: #0f5d58;
  border-color: rgba(15, 93, 88, 0.4);
}

.filter-chip.type-text {
  color: #6a4d86;
  border-color: rgba(106, 77, 134, 0.4);
}

.filter-chip.type-tag {
  color: #965e1d;
  border-color: rgba(150, 94, 29, 0.4);
}


.param-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  margin-right: 0.35rem;
}

.param-pill.kind-input {
  background: rgba(37, 91, 138, 0.12);
  color: #255b8a;
}

.param-pill.kind-output {
  background: rgba(122, 61, 42, 0.12);
  color: #7a3d2a;
}

.param-pill.type-number {
  background: rgba(15, 93, 88, 0.12);
  color: #0f5d58;
}

.param-pill.type-text {
  background: rgba(106, 77, 134, 0.12);
  color: #6a4d86;
}

.param-pill.type-tag {
  background: rgba(150, 94, 29, 0.12);
  color: #965e1d;
}


.library-table select {
  margin-top: 0.35rem;
}

.table-scroll {
  overflow-x: auto;
  overflow-y: visible;
  position: relative;
}

.table-scroll table {
  overflow: visible;
}

.rheo-table input[type="number"] {
  width: 100%;
  min-width: 90px;
}

.rheo-table td[data-derived] {
  color: #3c3a35;
  font-weight: 600;
}

.chart-card {
  margin-top: 1rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.chart-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.chart-controls label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
  color: var(--ink);
}

.chart-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.inline-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--ink);
}

.inline-field input {
  width: 120px;
}

.machine-table {
  width: 100%;
}

.machine-cell {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.machine-thumb {
  width: 72px;
  height: 54px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #f7f4ef;
}

.machine-thumb.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: var(--muted);
}

.machine-name {
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
}

.machine-name:hover {
  text-decoration: underline;
}

.setup-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.setup-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}

.recommendation-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.5);
}

.recommendation-item {
  padding: 0.25rem 0.4rem;
}

.recommendation-value {
  font-weight: 700;
  color: var(--ink);
}

.setup-summary.setup-summary-two {
  grid-template-columns: 1.4fr 1fr;
  align-items: start;
}

.setup-col {
  display: grid;
  gap: 0.4rem;
}

.setup-stack {
  display: grid;
  gap: 1rem;
}

.setup-row {
  display: grid;
  gap: 0.35rem;
}

.setup-value {
  font-weight: 600;
  color: var(--ink);
}

.setup-col-desc .setup-value {
  font-weight: 400;
}

.setup-field-list {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.setup-field-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(120px, 160px) minmax(140px, 160px) 40px;
  gap: 0.5rem;
  align-items: center;
}

.setup-field-row.has-code {
  grid-template-columns: minmax(160px, 1fr) minmax(120px, 160px) minmax(140px, 160px) 160px 40px;
}

.machine-code-input {
  font-size: 0.75rem;
  padding: 0.3rem 0.4rem;
  border-radius: 8px;
  border: 1px dashed var(--border);
  background: #f7f7f5;
  color: var(--ink-soft);
}

.field-with-code {
  display: grid;
  grid-template-columns: 1fr 160px;
  gap: 0.5rem;
  align-items: center;
}

.qual-summary-list {
  display: grid;
  gap: 0.35rem;
}

.qual-summary-item {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.icon-action {
  margin: 0;
}

.icon-button {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--accent-dark);
}

.icon-button.danger {
  color: var(--danger);
  border-color: rgba(180, 60, 60, 0.3);
}

.icon-button:hover {
  border-color: var(--accent);
}

.icon-button.danger:hover {
  border-color: var(--danger);
}

.back-link {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--ink);
  background: #fff;
  text-decoration: none;
}

.back-link .material-symbols-rounded {
  font-size: 20px;
}

button.pure-button-primary,
button.pure-button-secondary,
.pure-button-primary {
  background: var(--accent);
  border-radius: 999px;
}

.pure-button-secondary {
  background: var(--accent-2);
  color: #fff;
  border-radius: 999px;
}

.pure-button.danger {
  border-radius: 999px;
  color: #9f2d2d;
  border: 1px solid #e2b3ad;
}

table.pure-table {
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.table-compact td,
.table-compact th {
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--border);
}

.pure-table thead th {
  background: #efeae4;
}

.row-active {
  background: #e6f0ff !important;
  box-shadow: inset 4px 0 0 #2c7ea0;
}

.pure-table td.group-cell,
.group-cell {
  font-weight: 600;
  color: #1f2b38;
}

.pure-table td.group-material {
  background: #f3efe4;
}

.pure-table td.group-mold {
  background: #e6f2f5;
}

.pure-table td.group-barrel {
  background: #fbeadf;
}

.pure-table td.group-fill {
  background: #eaf6e4;
}

.pure-table td.group-pack-hold {
  background: #f1e9f8;
}

.pure-table td.group-screw {
  background: #efecec;
}

.pure-table td.group-clamp {
  background: #e9effb;
}

.pure-table td.group-outputs {
  background: #fff2e4;
}

.pure-table td.group-defects {
  background: #ffe9ef;
}

.pure-table td.group-general {
  background: #f4f4f4;
}

.mode-cell.mode-fixed {
  background: #fbe3d9;
}

.mode-cell.mode-range {
  background: #e7f4f0;
}

.mode-cell.mode-list {
  background: #f2f1ff;
}

.modal-frame {
  width: min(980px, 96vw);
  border: none;
  border-radius: 16px;
  padding: 0;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
}

.modal-body {
  padding: 1.25rem;
}

.modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(90deg, #f7e9dc, #f6f2ec);
}

.modal-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

.run-done {
  background: #e8f3e7;
}

.run-excluded {
  opacity: 0.5;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.5rem;
  margin: 0.2rem 0.2rem 0 0;
  border-radius: 999px;
  background: #f2f1ff;
  color: #3c3f68;
  font-size: 0.75rem;
}

.tag-chip-remove {
  gap: 0.35rem;
  padding-right: 0.3rem;
}

.tag-chip-remove button {
  border: none;
  background: transparent;
  color: #5c5f80;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
}

.field-grid label {
  display: block;
  margin-bottom: 0.25rem;
}

.field-grid input,
.field-grid select,
.field-grid textarea {
  width: 100%;
}

.field-span {
  grid-column: 1 / -1;
}

.field-chip {
  position: relative;
  display: grid;
  gap: 0.4rem;
  border: 1px solid var(--group-accent, var(--border));
  border-radius: 12px;
  padding: 0.9rem 0.75rem 0.75rem;
  background: #fffdf8;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.field-chip input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.field-chip::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 0;
  border-radius: 12px 12px 0 0;
  background: var(--group-accent, transparent);
}

.field-chip.is-active {
  border-color: var(--group-accent, #d97a2b);
  border-width: 2px;
  background: var(--group-bg, #fff0dd);
  box-shadow: 0 0 0 2px var(--group-accent, #d97a2b) inset, 0 8px 18px rgba(217, 122, 43, 0.12);
}

.field-chip.is-active::before {
  height: 10px;
}

.field-chip:hover {
  border-color: #e0b38d;
}

.field-title {
  font-weight: 600;
}

.field-meta {
  font-size: 0.8rem;
  color: var(--slate);
}

.field-table input {
  width: 100%;
  padding: 0.4rem 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
}

.qual-step-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.qual-step-card {
  position: relative;
  background: #f8f3ea;
  border: 1px solid #e2dad0;
  border-radius: 16px;
  padding: 1rem;
  display: grid;
  gap: 0.75rem;
  grid-template-rows: auto 1fr auto;
}

.qual-step-card .qual-step-btn {
  width: 100%;
  text-align: center;
}

.qual-step-card.is-locked {
  opacity: 0.8;
}

.qual-step-card.is-locked .qual-step-btn {
  pointer-events: none;
}

.qual-step-header {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: flex-start;
}

.qual-step-title {
  display: grid;
  gap: 0.25rem;
}

.qual-step-title-row {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.qual-step-meta {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.qual-status {
  font-size: 0.75rem;
  font-weight: 600;
  color: #5a5a52;
}

.qual-status.status-done {
  color: #1f7a4f;
}

.qual-summary {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.6rem;
  font-size: 0.75rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: 100%;
}

.qual-step-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
}

.qual-step-icon img {
  width: 36px;
  height: 36px;
  display: block;
}

.save-status {
  font-size: 0.8rem;
  color: #4b4b46;
  background: #f2efe8;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
}

.qual-field-table input,
.qual-field-table select {
  width: 100%;
  padding: 0.35rem 0.45rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
}

.output-group + .output-group {
  margin-top: 1rem;
}

.tag-cloud .pure-checkbox {
  display: inline-flex;
  align-items: center;
}

.outputs-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: 1rem;
  align-items: start;
}

.output-card {
  display: grid;
  gap: 0.45rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.65rem;
}

.output-tags {
  grid-column: span 2;
}

.tag-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.35rem 0.5rem;
}

.tag-select {
  position: relative;
}

.tag-selected {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  min-height: 0;
  align-items: center;
  padding: 0.25rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  align-content: flex-start;
  width: 100%;
}

.tag-selected .tag-chip {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag-placeholder {
  color: var(--muted);
  font-size: 0.9rem;
}

.tag-panel {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  min-width: 220px;
  max-width: 360px;
  max-height: 220px;
  overflow: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 24px rgba(16, 24, 40, 0.12);
  padding: 0.5rem;
  display: none;
}

.tag-panel.is-portal {
  position: fixed;
}

.tag-select {
  min-width: 160px;
  max-width: 260px;
  width: auto;
  display: inline-block;
}

.tag-panel {
  z-index: 2000;
}

.tag-select.is-open .tag-panel {
  display: block;
}

.tag-filter {
  width: 100%;
  margin-bottom: 0.5rem;
}

.tag-options {
  display: grid;
  gap: 0.35rem;
}

.tag-option {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.template-preview {
  font-size: 0.8rem;
  color: var(--muted);
  min-height: 1rem;
}

.template-preview.is-visible {
  margin-top: 0.2rem;
}

.template-preview.is-resolved {
  color: #2f8f5b;
}

.template-preview.is-missing {
  color: #b94a48;
}

.tag-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.tag-toggle input {
  width: 14px;
  height: 14px;
}

@media (max-width: 1000px) {
  .outputs-grid {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }
  .output-tags {
    grid-column: span 2;
  }
}

@media (max-width: 680px) {
  .outputs-grid {
    grid-template-columns: 1fr;
  }
  .output-tags {
    grid-column: span 1;
  }
}

.tabs {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.tabs a {
  text-decoration: none;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--slate);
}

.tabs a.active {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

.form-grid {
  display: grid;
  gap: 0.75rem;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.75rem 1rem;
  align-items: center;
}

.form-grid label {
  font-weight: 600;
  display: block;
  margin-bottom: 0.25rem;
}

.form-grid .toggle {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0;
  font-weight: 500;
}

.form-grid .toggle span {
  line-height: 1.2;
}

input[type="text"],
input[type="number"],
textarea,
select {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
}

.readonly-field {
  padding: 0.65rem 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #f4f2ee;
  min-height: 42px;
}

.value-list {
  display: grid;
  gap: 0.6rem;
  max-width: 640px;
}

.value-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.6rem;
  border-radius: 10px;
  background: #f7f4ef;
  border: 1px solid var(--border);
}

.value-label {
  font-weight: 600;
}

.value-dots {
  height: 1px;
  background-image: radial-gradient(#c6bdb2 1px, transparent 1px);
  background-size: 6px 6px;
  background-position: left center;
}

.value-value {
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}

textarea {
  min-height: 90px;
}

.run-form input[type="number"],
.run-form input[type="text"],
.run-form textarea {
  font-size: 1rem;
  padding: 0.8rem;
}

.run-controls {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.chart-card {
  min-height: 320px;
}

.small-note {
  color: var(--slate);
  font-size: 0.85rem;
}

.editor-surface {
  min-height: 60vh;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: #fff;
  padding: 1.5rem;
  margin-top: 1rem;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin-top: 1rem;
  position: sticky;
  /* top: 4.2rem; */
  top:0;
  z-index: 20;
  padding: 0.55rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(245, 241, 235, 0.96);
  backdrop-filter: blur(2px);
}

.editor-toolbar.is-disabled {
  opacity: 0.6;
}

.button-sm {
  padding: 0.35rem 0.6rem;
  font-size: 0.82rem;
}

.toolbar-select {
  width: auto;
  flex: 0 0 auto;
  display: inline-block;
  height: 34px;
  border: 1px solid #d8d2c5;
  border-radius: 6px;
  background: #fff;
  color: #2d2d2d;
  padding: 0 0.45rem;
  font-size: 0.8rem;
  min-width: 84px;
}

.toolbar-select:disabled {
  opacity: 0.6;
}

.button-sm.icon-only {
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.button-sm.icon-only .material-symbols-rounded {
  font-size: 18px;
}

.toolbar-sep {
  width: 1px;
  background: #d8d2c5;
  margin: 0 0.15rem;
}

.table-tools {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.25rem;
  border: 1px solid #d8d2c5;
  border-radius: 8px;
  background: #f8f6f2;
  position: relative;
}

.image-tools {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.25rem;
  border: 1px solid #d8d2c5;
  border-radius: 8px;
  background: #f8f6f2;
}

.table-ops {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.toolbar-conditional {
  display: none;
}

.toolbar-conditional.is-visible {
  display: inline-flex;
}

.image-op {
  min-width: 34px;
  height: 34px;
  padding: 0 0.35rem;
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1;
}

.image-op.danger {
  color: #8e2f2f;
  border-color: #e1b8b2;
}

.table-op {
  min-width: 34px;
  height: 34px;
  padding: 0 0.35rem;
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1;
}

.table-op.danger {
  color: #8e2f2f;
  border-color: #e1b8b2;
}

.table-picker {
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 0;
  width: 224px;
  padding: 0.5rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(22, 24, 32, 0.12);
  z-index: 30;
}

.table-picker-label {
  font-size: 0.78rem;
  color: var(--slate);
  margin-bottom: 0.45rem;
  font-weight: 700;
}

.table-picker-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 0.2rem;
}

.table-picker-cell {
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 1px solid #d8d2c5;
  border-radius: 3px;
  background: #fff;
  cursor: pointer;
  padding: 0;
}

.table-picker-cell.active {
  background: #f0c9a7;
  border-color: #df9f6a;
}

.pure-button-primary.is-saving {
  position: relative;
  opacity: 0.9;
}

.pure-button-primary.is-saving::after {
  content: "";
  position: absolute;
  right: 0.45rem;
  top: 50%;
  width: 0.42rem;
  height: 0.42rem;
  margin-top: -0.21rem;
  border-radius: 50%;
  background: #fff;
  animation: savePulse 0.8s ease-in-out infinite;
}

@keyframes savePulse {
  0% { transform: scale(0.8); opacity: 0.4; }
  50% { transform: scale(1); opacity: 1; }
  100% { transform: scale(0.8); opacity: 0.4; }
}

.editor-surface .ProseMirror {
  outline: none;
  min-height: 56vh;
  line-height: 1.5;
}

.editor-surface .ProseMirror h1,
.editor-surface .ProseMirror h2,
.editor-surface .ProseMirror h3,
.editor-surface .ProseMirror h4 {
  margin: 0.9rem 0 0.55rem;
}

.editor-surface .ProseMirror p {
  margin: 0.45rem 0;
}

.editor-surface .ProseMirror ul,
.editor-surface .ProseMirror ol {
  margin: 0.45rem 0 0.45rem 1.35rem;
}

.editor-surface .ProseMirror blockquote {
  margin: 0.7rem 0;
  padding-left: 0.8rem;
  border-left: 3px solid #d8d2c5;
  color: #6d6a63;
}

.editor-surface .ProseMirror table {
  border-collapse: collapse;
  margin: 0.8rem 0;
  width: 100%;
}

.editor-surface .ProseMirror th,
.editor-surface .ProseMirror td {
  border: 1px solid #d8d2c5;
  padding: 0.4rem 0.5rem;
  vertical-align: top;
}

.editor-surface .ProseMirror img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

.editor-surface .ProseMirror img.ProseMirror-selectednode {
  outline: 2px solid #4a86d4;
  outline-offset: 2px;
}

.editor-surface .ProseMirror img[data-width="25%"] {
  width: 25%;
}

.editor-surface .ProseMirror img[data-width="50%"] {
  width: 50%;
}

.editor-surface .ProseMirror img[data-width="75%"] {
  width: 75%;
}

.editor-surface .ProseMirror img[data-width="100%"] {
  width: 100%;
}

.editor-surface .ProseMirror img[data-align="left"] {
  display: block;
  margin-left: 0;
  margin-right: auto;
}

.editor-surface .ProseMirror img[data-align="center"] {
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.editor-surface .ProseMirror img[data-align="right"] {
  display: block;
  margin-left: auto;
  margin-right: 0;
}

.editor-surface .ProseMirror figcaption {
  font-size: 0.82rem;
  color: var(--slate);
  margin-top: 0.2rem;
}

.save-status {
  margin-top: 0.5rem;
}

.report-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin-top: 1rem;
}

.report-line {
  height: 1px;
  margin-top: 0.35rem;
  background-image: radial-gradient(#c6bdb2 1px, transparent 1px);
  background-size: 6px 6px;
  background-position: left center;
}

.report-description {
  margin-top: 1rem;
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #f7f4ef;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
  position: relative;
}

.toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle .track {
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: #c9ced9;
  position: relative;
  transition: background 0.2s ease;
}

.toggle .track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.toggle input:checked + .track {
  background: #2f9c74;
}

.toggle input:checked + .track::after {
  transform: translateX(16px);
}

.toggle input:disabled + .track {
  background: #e3e6ee;
  cursor: not-allowed;
}

.toggle input:disabled + .track::after {
  background: #f6f7fb;
}

.toggle-label {
  font-size: 0.9rem;
  color: #3a3f4a;
}

.group-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.group-chip {
  border: 1px solid var(--chip-color, #c9ced9);
  background: #fff;
  color: #2b2f36;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.group-chip::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--chip-color, #c9ced9);
}

.group-chip.active {
  background: var(--chip-bg, #2b2f36);
  color: #1f232a;
}

.group-row {
  border-left: 4px solid var(--group-color, #d6dae3);
  background: linear-gradient(90deg, var(--group-bg, #f7f8fb), transparent 70%);
}

.factor-settings {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.4rem;
  min-width: 220px;
}

.factor-settings input,
.factor-settings select {
  width: 100%;
}

.settings-range {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)) 70px;
  gap: 0.4rem;
}

.settings-values {
  display: block;
}

tr[data-mode="fixed"] .settings-range,
tr[data-mode="fixed"] .settings-range {
  display: none;
}

tr[data-mode="range"] .settings-values {
  display: none;
}

tr[data-mode="list"] .settings-range,
tr[data-mode="list"] .settings-range {
  display: none;
}

@media (max-width: 700px) {
  .top-nav {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .nav-links a {
    margin-left: 0;
    margin-right: 0.8rem;
  }
}

.site-footer {
  margin-top: auto;
  padding: 1.5rem 1.5rem 2rem;
  background: linear-gradient(90deg, #f8ede0, #f4efe9);
  border-top: 1px solid var(--border);
}

.site-footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.footer-brand {
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink);
}

.footer-links {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--slate);
  text-decoration: none;
  font-weight: 600;
}

.footer-links a:hover {
  text-decoration: underline;
}

.journal-compose {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fffaf5;
  padding: 0.75rem;
  margin-bottom: 1rem;
}

.journal-toolbar {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.journal-compose textarea {
  width: 100%;
  resize: vertical;
}

.journal-editor {
  width: 100%;
  min-height: 120px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  padding: 0.55rem 0.65rem;
  outline: none;
  line-height: 1.5;
}

.journal-editor:empty::before {
  content: attr(data-placeholder);
  color: #8a8f97;
}

.journal-compose-footer {
  margin-top: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.journal-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

.journal-rail {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: center;
  position: fixed;
  right: 0.8rem;
  top: 50%;
  transform: translateY(-50%);
  max-height: none;
  overflow: visible;
  padding-top: 0.2rem;
  z-index: 40;
}

.journal-rail-dot {
  position: relative;
  width: 8px;
  height: 20px;
  border-radius: 999px;
  border: none;
  background: #b8c0cc;
  cursor: pointer;
  padding: 0;
  transition: transform 140ms ease, box-shadow 140ms ease, opacity 140ms ease;
}

.journal-rail-dot:hover {
  background: #7e8aa0;
}

.journal-rail-dot.is-active {
  transform: translateX(-4px);
  box-shadow: 0 0 0 2px rgba(32, 36, 43, 0.1);
}

.journal-rail-dot::after {
  content: none;
  position: absolute;
  right: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.72rem;
  line-height: 1.25;
  padding: 0.25rem 0.45rem;
  border-radius: 7px;
  border: 1px solid #d7d7d2;
  background: #fff;
  color: #20242b;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
  transition: opacity 120ms ease;
  z-index: 41;
}

.journal-rail-dot::before {
  content: none;
  position: absolute;
  right: calc(100% + 3px);
  top: 50%;
  width: 6px;
  height: 6px;
  transform: translateY(-50%) rotate(45deg);
  border-right: 1px solid #d7d7d2;
  border-top: 1px solid #d7d7d2;
  background: #fff;
  opacity: 0;
  transition: opacity 120ms ease;
  z-index: 41;
}

.journal-rail-dot:hover::after,
.journal-rail-dot:hover::before,
.journal-rail-dot:focus-visible::after,
.journal-rail-dot:focus-visible::before {
  opacity: 1;
}

.entity-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.12rem 0.48rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
}

.entity-experiment {
  background: #eef2f7;
  color: #4d5a6d;
  border-color: #d3dde9;
}

.entity-qualification_step {
  background: #efe9ff;
  color: #5b4696;
  border-color: #d9cdf7;
}

.entity-doe {
  background: #e8f3ff;
  color: #2e5f90;
  border-color: #cce2f7;
}

.entity-run {
  background: #eaf7ee;
  color: #2f6d49;
  border-color: #cde7d5;
}

.entity-report {
  background: #fff1e6;
  color: #8c4f27;
  border-color: #f5d9c2;
}

.entity-task {
  background: #ffe8e8;
  color: #8b3e3e;
  border-color: #f1caca;
}

.journal-rail-dot.entity-experiment {
  background: #9fb2c8;
}

.journal-rail-dot.entity-qualification_step {
  background: #9f86dd;
}

.journal-rail-dot.entity-doe {
  background: #6ba8de;
}

.journal-rail-dot.entity-run {
  background: #63b083;
}

.journal-rail-dot.entity-report {
  background: #d6925f;
}

.journal-rail-dot.entity-task {
  background: #d97777;
}

.notes-search {
  margin-left: auto;
  min-width: 170px;
  max-width: 240px;
  padding: 0.36rem 0.55rem;
  border: 1px solid #d9d9d4;
  border-radius: 999px;
  background: #fbfbf9;
  font-size: 0.86rem;
}

.journal-feed .notes-drawer-toolbar {
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.5rem;
}

.journal-entity-filters {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: nowrap;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.journal-filter-chip {
  border: 1px solid #d9d9d4;
  background: #fbfbf9;
  color: #4f5560;
  border-radius: 999px;
  padding: 0.18rem 0.55rem;
  font-size: 0.78rem;
  line-height: 1.35;
  cursor: pointer;
  white-space: nowrap;
  flex: 0 0 auto;
}

.journal-filter-chip.is-active {
  box-shadow: inset 0 0 0 1px rgba(30, 31, 36, 0.18);
  font-weight: 700;
}

.journal-filter-chip.entity-experiment {
  background: #f7f9fc;
  border-color: #dbe3ee;
  color: #4d5a6d;
}

.journal-filter-chip.entity-qualification_step {
  background: #f8f5ff;
  border-color: #e1d8f7;
  color: #5b4696;
}

.journal-filter-chip.entity-doe {
  background: #f1f8ff;
  border-color: #d8e8f8;
  color: #2e5f90;
}

.journal-filter-chip.entity-run {
  background: #f2faf5;
  border-color: #d6eadf;
  color: #2f6d49;
}

.journal-filter-chip.entity-report {
  background: #fff8f1;
  border-color: #f3dfcb;
  color: #8c4f27;
}

.journal-filter-chip.entity-task {
  background: #fff3f3;
  border-color: #f3d7d7;
  color: #8b3e3e;
}

.journal-feed .notes-drawer-toolbar .notes-search {
  margin-left: 0;
  flex: 0 0 auto;
}

.journal-feed {
  display: grid;
  gap: 0.6rem;
}

.journal-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
  background: #fff;
}

.journal-item-title-link {
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

.journal-item-title-link:hover {
  text-decoration: underline;
}

.journal-item.entity-experiment {
  background: #f7f9fc;
  border-color: #dbe3ee;
}

.journal-item.entity-qualification_step {
  background: #f8f5ff;
  border-color: #e1d8f7;
}

.journal-item.entity-doe {
  background: #f1f8ff;
  border-color: #d8e8f8;
}

.journal-item.entity-run {
  background: #f2faf5;
  border-color: #d6eadf;
}

.journal-item.entity-report {
  background: #fff8f1;
  border-color: #f3dfcb;
}

.journal-item.entity-task {
  background: #fff3f3;
  border-color: #f3d7d7;
}

.journal-item-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
}

.journal-item-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.icon-button.tiny {
  width: 28px;
  height: 28px;
  min-width: 28px;
  padding: 0;
}

.icon-button.tiny .material-symbols-rounded {
  font-size: 17px;
}

.journal-item-body {
  margin-top: 0.4rem;
  line-height: 1.5;
}

.journal-item-body p {
  margin: 0.35rem 0;
}

.journal-item-body ul {
  margin: 0.35rem 0 0.35rem 1.1rem;
  padding: 0;
}

.journal-item-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.45rem 0;
}

.journal-item-body th,
.journal-item-body td {
  border: 1px solid #ddd8d2;
  padding: 0.28rem 0.45rem;
  vertical-align: top;
  text-align: left;
}

.journal-item-body .md-checklist {
  list-style: none;
  margin-left: 0;
}


.notes-drawer-toggle {
  position: fixed;
  right: 1rem;
  bottom: 0.5rem;
  z-index: 25;
}

.notes-journal-toggle {
  position: fixed;
  right: 4.25rem;
  bottom: 0.5rem;
  z-index: 25;
}

.notes-drawer {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  height: auto;
  max-height: none;
  display: none;
  grid-template-rows: auto 1fr;
  border: 1px solid var(--border);
  border-radius: 0;
  background: #fff;
  box-shadow: 0 18px 30px rgba(0, 0, 0, 0.16);
  z-index: 24;
}

.notes-drawer.is-open {
  display: grid;
}

.notes-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--border);
}

.notes-drawer-head-inline {
  justify-content: flex-start;
  flex-wrap: nowrap;
}

.notes-drawer-head-inline > strong {
  margin-right: 0.25rem;
  flex: 0 0 auto;
}

.notes-drawer-head-inline > .toggle {
  flex: 0 1 auto;
  min-width: 0;
}

.notes-drawer-head-inline > .small-note {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.notes-drawer-head-inline > .notes-search {
  margin-left: 0;
  flex: 0 0 auto;
}

.notes-drawer-head-inline > .section-actions {
  margin-left: 0;
  flex: 0 0 auto;
}

.notes-drawer-toolbar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.9rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: nowrap;
}

.notes-drawer-toolbar .toggle {
  flex: 0 1 auto;
  min-width: 0;
}

.notes-drawer-toolbar .small-note {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.notes-drawer-body {
  display: grid;
  grid-template-columns: minmax(320px, 44%) minmax(420px, 56%);
  gap: 1rem;
  padding: 0.8rem 0.9rem;
  min-height: 0;
}

.notes-drawer .journal-rail {
  right: 1.1rem;
  top: 50%;
  max-height: none;
}

.notes-drawer-body.no-compose {
  grid-template-columns: 1fr;
}

.notes-pane {
  min-height: 0;
}

.notes-pane-compose {
  border-right: 1px solid var(--border);
  padding-right: 0.9rem;
}

.notes-pane-feed {
  min-width: 0;
}

.rail-tooltip {
  position: fixed;
  left: 0;
  top: 0;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.76rem;
  line-height: 1.25;
  padding: 0.32rem 0.52rem;
  border-radius: 8px;
  border: 1px solid #d7d7d2;
  background: #fff;
  color: #20242b;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.16);
  transform: translate(-8px, -50%);
  z-index: 70;
  transition: opacity 100ms ease;
}

.rail-tooltip.is-visible {
  opacity: 1;
}

.rail-tooltip.is-multiline {
  white-space: pre-line;
  max-width: 240px;
  overflow: visible;
  text-overflow: initial;
}

.notes-feed-scroll {
  overflow: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-right: 2.8rem;
  height: 100%;
}

.notes-feed-scroll::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

body.notes-drawer-open {
  overflow: hidden;
}

.notes-compose {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  height: 100%;
}

.notes-compose textarea {
  width: 100%;
  resize: vertical;
}

.notes-compose .journal-editor {
  flex: 1 1 auto;
  min-height: 220px;
}

.notes-compose .journal-editor .ProseMirror {
  min-height: 220px;
  outline: none;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.notes-compose .journal-editor .ProseMirror h1,
.notes-compose .journal-editor .ProseMirror h2,
.notes-compose .journal-editor .ProseMirror h3 {
  margin: 0.65rem 0 0.35rem;
}

.notes-compose .journal-editor .ProseMirror p {
  margin: 0.35rem 0;
}

.notes-compose .journal-editor .ProseMirror ul,
.notes-compose .journal-editor .ProseMirror ol {
  margin: 0.35rem 0 0.35rem 1.1rem;
}

.notes-compose .journal-editor .ProseMirror blockquote {
  margin: 0.45rem 0;
  padding-left: 0.7rem;
  border-left: 3px solid #d7d7d2;
  color: #505764;
}

.notes-compose .journal-editor .ProseMirror table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.5rem 0;
}

.notes-compose .journal-editor .ProseMirror th,
.notes-compose .journal-editor .ProseMirror td {
  border: 1px solid #ddd8d2;
  padding: 0.3rem 0.45rem;
  vertical-align: top;
}

.notes-compose .journal-editor .ProseMirror .column-resize-handle {
  background: rgba(45, 120, 210, 0.45);
  width: 3px;
}

.notes-compose .journal-editor .ProseMirror img {
  max-width: 100%;
  height: auto;
}

.notes-compose-footer {
  margin-top: 0.4rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

@media (max-width: 900px) {
  .messages-workspace {
    height: auto;
    min-height: 0;
  }

  .container.messages-page-container {
    padding: 0.25rem;
  }

  .messages-layout {
    grid-template-columns: 1fr;
    height: auto;
    min-height: auto;
  }

  .messages-sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 48vh;
  }

  .messages-thread {
    min-height: 60vh;
  }

  .messages-rail {
    border-left: none;
    border-top: 1px solid var(--border);
    min-height: 240px;
  }

  .messages-add-member-form {
    flex-direction: column;
    align-items: stretch;
  }

  .messages-add-member-form select {
    min-width: 0;
    width: 100%;
  }

  .messages-bubble {
    max-width: 92%;
  }

  .notes-drawer-head-inline {
    flex-wrap: wrap;
  }

  .notes-drawer-head-inline > .section-actions {
    margin-left: auto;
  }

  .notes-drawer-toolbar {
    flex-wrap: wrap;
  }

  .journal-layout,
  .notes-drawer-body {
    grid-template-columns: 1fr;
  }

  .notes-pane-compose {
    border-right: none;
    padding-right: 0;
  }

  .journal-rail,
  .notes-drawer .journal-rail {
    display: none;
  }
}

.calendar-host {
  margin-top: 0.75rem;
  position: relative;
}

.calendar-tools {
  margin-top: 0.65rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
}

.calendar-tools input[type="date"] {
  min-width: 10.5rem;
}

.calendar-host .fc {
  --fc-border-color: #dddcd6;
  --fc-page-bg-color: #fcfcfa;
  --fc-neutral-bg-color: #f5f4ef;
  --fc-list-event-hover-bg-color: #f4f2ea;
  --fc-today-bg-color: #f3eee3;
}

.calendar-host .fc .fc-toolbar-title {
  font-size: 1.02rem;
}

.calendar-host .fc .fc-event {
  border-radius: 8px;
  border-width: 1px;
  border-style: solid;
  padding: 1px 4px;
}

.calendar-host .fc .calendar-event-selected,
.calendar-host .fc .fc-event.calendar-event-selected,
.calendar-host .fc .fc-daygrid-event.calendar-event-selected,
.calendar-host .fc .fc-timegrid-event.calendar-event-selected {
  border: 4px solid #ff2b2b !important;
  box-shadow: 0 0 0 2px #ffffff, 0 0 0 6px rgba(255, 43, 43, 0.9), 0 4px 12px rgba(255, 43, 43, 0.25) !important;
  outline: 2px solid #ff2b2b !important;
  outline-offset: -2px !important;
  transform: translateY(-1px) scale(1.01);
  z-index: 5;
  filter: none !important;
}

.calendar-host .fc .calendar-event-selected .fc-event-title,
.calendar-host .fc .fc-event.calendar-event-selected .fc-event-title {
  font-weight: 700;
  color: #121212 !important;
}

.calendar-host .fc .calendar-event-selected .fc-event-title::before,
.calendar-host .fc .fc-event.calendar-event-selected .fc-event-title::before {
  content: "● ";
}

.calendar-host .fc .fc-event.calendar-event-open {
  filter: saturate(0.88);
}

.calendar-host .fc .fc-event.calendar-event-done {
  filter: saturate(1.1);
}

/* Calendar interactions should not trigger native text selection. */
.calendar-host,
.calendar-host * {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
}

.calendar-host .fc,
.calendar-host .fc .fc-scrollgrid,
.calendar-host .fc .fc-col-header-cell,
.calendar-host .fc .fc-daygrid-day,
.calendar-host .fc .fc-daygrid-day-frame,
.calendar-host .fc .fc-daygrid-day-number,
.calendar-host .fc .fc-event,
.calendar-host .fc .fc-event-title,
.calendar-host .fc .fc-toolbar-title,
.calendar-host .fc .fc-button {
  -webkit-user-select: none !important;
  -moz-user-select: none !important;
  user-select: none !important;
}

.calendar-host ::selection {
  background: transparent;
}

.calendar-lasso {
  position: absolute;
  border: 2px dashed #0b5fff;
  background: rgba(11, 95, 255, 0.14);
  pointer-events: none;
  z-index: 20;
}

.process-calendar-panel > summary {
  cursor: pointer;
  list-style: none;
}

.process-calendar-panel > summary::-webkit-details-marker {
  display: none;
}
