/* Laws of Korea — sentence highlighter and memo panel */
:root {
  --lok-panel-width: 360px;
  --lok-blue: #245eea;
  --lok-blue-soft: #eef4ff;
  --lok-border: #dfe5ed;
  --lok-panel: #ffffff;
  --lok-panel-soft: #f7f9fc;
  --lok-text: #172033;
  --lok-muted: #657086;
  --lok-danger: #b42318;
}

.reader-body-shell.lok-annotation-mounted {
  grid-template-columns: 225px minmax(0, 1fr) var(--lok-panel-width);
}
.reader-hide-toc .reader-body-shell.lok-annotation-mounted {
  grid-template-columns: minmax(0, 1fr) var(--lok-panel-width);
}
.lok-standalone-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--lok-panel-width);
  gap: 16px;
  align-items: start;
  min-width: 0;
}
.lok-standalone-shell > #reading-panes {
  min-width: 0;
}

.lok-annotation-panel {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  color: var(--lok-text);
  background: var(--lok-panel);
  border-left: 1px solid var(--lok-border);
  font-family: "Noto Sans KR", "Malgun Gothic", system-ui, sans-serif;
  overflow: hidden;
}
.lok-annotation-panel[hidden] {
  display: none !important;
}
.lok-panel-standalone {
  position: sticky;
  top: 72px;
  height: calc(100vh - 92px);
  border: 1px solid var(--lok-border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(22, 33, 55, 0.08);
}
.lok-panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 15px 12px;
  border-bottom: 1px solid var(--lok-border);
  background: var(--lok-panel);
  flex: 0 0 auto;
}
.lok-panel-header > div {
  min-width: 0;
}
.lok-panel-header strong {
  display: block;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
}
.lok-panel-header small {
  display: block;
  max-width: 270px;
  margin-top: 4px;
  color: var(--lok-muted);
  font-size: 9px;
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lok-panel-header > button {
  width: 29px;
  height: 29px;
  border: 1px solid var(--lok-border);
  border-radius: 7px;
  color: var(--lok-muted);
  background: #fff;
  font-size: 20px;
  line-height: 1;
}
.lok-main-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  padding: 9px 10px;
  border-bottom: 1px solid var(--lok-border);
  background: var(--lok-panel-soft);
  flex: 0 0 auto;
}
.lok-main-tabs button {
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--lok-muted);
  font-size: 11px;
  font-weight: 600;
}
.lok-main-tabs button.active {
  border-color: #8eb2ff;
  color: var(--lok-blue);
  background: #fff;
  box-shadow: 0 2px 7px rgba(36, 94, 234, 0.08);
}
.lok-panel-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 10px;
  background: var(--lok-panel-soft);
  scrollbar-width: thin;
}
.lok-panel-section {
  padding: 12px;
  border: 1px solid var(--lok-border);
  border-radius: 10px;
  background: #fff;
}
.lok-panel-section + .lok-panel-section {
  margin-top: 10px;
}
.lok-section-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.lok-section-title.inline {
  align-items: center;
}
.lok-section-title strong {
  display: block;
  font-size: 12px;
  line-height: 1.45;
}
.lok-section-title small {
  display: block;
  margin-top: 3px;
  color: var(--lok-muted);
  font-size: 9px;
  line-height: 1.55;
}
.lok-color-picker {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
}
.lok-color-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 0;
  min-height: 32px;
  padding: 5px 4px;
  border: 1px solid var(--lok-border);
  border-radius: 7px;
  color: var(--lok-text);
  background: #fff;
  font-size: 9px;
  white-space: nowrap;
}
.lok-color-chip i,
.lok-row-color,
.lok-group-nav i,
.lok-selection-menu i {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  border-radius: 4px;
  background: var(--lok-chip);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.04);
}
.lok-color-chip.active {
  border-color: var(--lok-blue);
  color: var(--lok-blue);
  background: var(--lok-blue-soft);
  font-weight: 700;
}
.lok-default-category {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  color: var(--lok-muted);
  font-size: 9px;
}
.lok-default-category select,
.lok-memo-editor select,
.lok-memo-editor textarea {
  width: 100%;
  border: 1px solid var(--lok-border);
  border-radius: 7px;
  color: var(--lok-text);
  background: #fff;
  font: inherit;
}
.lok-default-category select,
.lok-memo-editor select {
  padding: 7px 8px;
  font-size: 10px;
}
.lok-group-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  margin-bottom: 9px;
  padding: 3px;
  border-radius: 8px;
  background: #f0f3f8;
}
.lok-group-tabs button {
  min-height: 31px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--lok-muted);
  font-size: 10px;
}
.lok-group-tabs button.active {
  border-color: #9dbbff;
  color: var(--lok-blue);
  background: #fff;
  font-weight: 700;
}
.lok-highlight-browser {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 8px;
  min-height: 210px;
}
.lok-group-nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 5px;
  border: 1px solid var(--lok-border);
  border-radius: 8px;
  background: #fbfcfe;
  max-height: 330px;
  overflow: auto;
}
.lok-group-nav button {
  display: grid;
  grid-template-columns: 15px minmax(0, 1fr) auto;
  align-items: center;
  gap: 5px;
  min-height: 30px;
  padding: 5px 6px;
  border-radius: 6px;
  color: var(--lok-text);
  text-align: left;
  font-size: 9px;
}
.lok-group-nav button:first-child {
  grid-template-columns: minmax(0, 1fr) auto;
}
.lok-group-nav button.active {
  color: #1749b8;
  background: #dfeaff;
  font-weight: 700;
}
.lok-group-nav b {
  color: var(--lok-muted);
  font-size: 8px;
  font-weight: 600;
}
.lok-highlight-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 330px;
  overflow: auto;
  padding-right: 2px;
}
.lok-highlight-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 29px;
  align-items: stretch;
  border: 1px solid var(--lok-border);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}
.lok-highlight-row.selected {
  border-color: #92b3ff;
  box-shadow: 0 0 0 2px rgba(36, 94, 234, 0.08);
}
.lok-highlight-open {
  display: grid;
  grid-template-columns: 13px minmax(0, 1fr);
  gap: 7px;
  min-width: 0;
  padding: 8px;
  text-align: left;
}
.lok-highlight-open > span {
  min-width: 0;
}
.lok-highlight-open strong,
.lok-highlight-open q,
.lok-highlight-open small {
  display: block;
}
.lok-highlight-open strong {
  color: var(--lok-muted);
  font-size: 8px;
}
.lok-highlight-open q {
  margin-top: 3px;
  overflow: hidden;
  color: var(--lok-text);
  font-size: 9px;
  line-height: 1.45;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.lok-highlight-open q::before,
.lok-highlight-open q::after,
.lok-memo-card q::before,
.lok-memo-card q::after,
.lok-memo-editor q::before,
.lok-memo-editor q::after {
  content: none;
}
.lok-highlight-open small {
  margin-top: 4px;
  overflow: hidden;
  color: var(--lok-muted);
  font-size: 8px;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.lok-icon-button,
.lok-card-actions button {
  color: var(--lok-muted);
  font-size: 12px;
}
.lok-icon-button:hover,
.lok-card-actions button:hover {
  color: var(--lok-blue);
}
.lok-empty {
  display: grid;
  place-items: center;
  min-height: 120px;
  padding: 18px;
  border: 1px dashed #cbd4e3;
  border-radius: 8px;
  color: var(--lok-muted);
  background: #fff;
  font-size: 10px;
  line-height: 1.8;
  text-align: center;
}
.lok-new-memo {
  flex: 0 0 auto;
  padding: 7px 10px;
  border: 1px solid #8eb2ff;
  border-radius: 7px;
  color: var(--lok-blue);
  background: #fff;
  font-size: 9px;
  font-weight: 700;
}
.lok-memo-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.lok-memo-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px;
  border: 1px solid var(--lok-border);
  border-radius: 9px;
  background: #fff;
  overflow: hidden;
}
.lok-memo-card.selected {
  border-color: #88acff;
  box-shadow: 0 0 0 2px rgba(36, 94, 234, 0.08);
}
.lok-memo-main {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 5px 7px;
  min-width: 0;
  padding: 9px;
  text-align: left;
}
.lok-sentence-badge {
  grid-row: 1;
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 2px 6px;
  border-radius: 5px;
  background: color-mix(in srgb, var(--lok-chip) 45%, white);
  font-size: 8px;
  font-weight: 700;
}
.lok-memo-card q {
  grid-column: 2;
  overflow: hidden;
  align-self: center;
  font-size: 9px;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.lok-memo-card strong {
  grid-column: 1 / -1;
  padding-top: 3px;
  font-size: 10px;
}
.lok-memo-card small {
  grid-column: 1 / -1;
  color: var(--lok-muted);
  font-size: 8px;
}
.lok-card-actions {
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-left: 1px solid #edf0f5;
}
.lok-card-actions button {
  flex: 1;
  min-height: 28px;
}
.lok-memo-editor {
  margin-top: 10px;
  padding: 11px;
  border: 1px solid #9db9fb;
  border-radius: 10px;
  background: #f9fbff;
}
.lok-memo-editor header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 11px;
}
.lok-memo-editor header > div {
  min-width: 0;
}
.lok-memo-editor header strong,
.lok-memo-editor header q {
  display: block;
}
.lok-memo-editor header strong {
  font-size: 11px;
}
.lok-memo-editor header q {
  margin-top: 4px;
  overflow: hidden;
  color: var(--lok-muted);
  font-size: 8px;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.lok-memo-editor header button {
  width: 26px;
  height: 26px;
  color: var(--lok-muted);
  font-size: 18px;
}
.lok-memo-editor > label {
  display: grid;
  gap: 5px;
  margin-top: 9px;
}
.lok-memo-editor label > span,
.lok-memo-editor legend {
  color: var(--lok-muted);
  font-size: 8px;
}
.lok-memo-editor fieldset {
  margin: 9px 0 0;
  padding: 0;
  border: 0;
}
.lok-memo-editor textarea {
  resize: vertical;
  min-height: 92px;
  padding: 9px;
  font-size: 10px;
  line-height: 1.65;
}
.lok-editor-actions {
  display: flex;
  gap: 7px;
  margin-top: 10px;
}
.lok-editor-actions button {
  flex: 1;
  min-height: 32px;
  border: 1px solid var(--lok-blue);
  border-radius: 7px;
  color: #fff;
  background: var(--lok-blue);
  font-size: 9px;
  font-weight: 700;
}
.lok-editor-actions button.danger {
  border-color: #f1c5c2;
  color: var(--lok-danger);
  background: #fff;
}

mark.lok-user-highlight {
  position: relative;
  border-radius: 3px;
  padding: 0 1px;
  color: inherit !important;
  cursor: pointer;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
mark.lok-user-highlight:hover {
  outline: 2px solid rgba(36, 94, 234, 0.35);
  outline-offset: 1px;
}
mark.lok-user-highlight[data-has-memo="true"]::after {
  content: "✎";
  display: inline-block;
  margin-left: 2px;
  color: #34425a;
  font-size: 0.68em;
  font-weight: 700;
  vertical-align: super;
}
mark.lok-color-yellow { background: #ffe66d !important; }
mark.lok-color-green { background: #a8e6a3 !important; }
mark.lok-color-blue { background: #a9d1ff !important; }
mark.lok-color-pink { background: #ffb5d0 !important; }
mark.lok-color-orange { background: #ffc27a !important; }
mark.lok-pulse {
  animation: lok-pulse 0.7s ease-in-out 2;
}
@keyframes lok-pulse {
  50% { box-shadow: 0 0 0 4px rgba(36, 94, 234, 0.35); }
}

.lok-selection-menu {
  position: fixed;
  z-index: 100000;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px;
  border: 1px solid #cbd5e4;
  border-radius: 9px;
  color: var(--lok-text);
  background: #fff;
  box-shadow: 0 12px 35px rgba(20, 34, 60, 0.22);
}
.lok-selection-menu > span {
  padding: 0 4px;
  color: var(--lok-muted);
  font-size: 9px;
  font-weight: 700;
}
.lok-selection-menu button {
  display: grid;
  place-items: center;
  min-width: 28px;
  height: 28px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: #fff;
}
.lok-selection-menu button:hover {
  border-color: #8eaef1;
  background: #f4f7ff;
}
.lok-selection-menu .lok-selection-memo {
  width: auto;
  padding: 0 8px;
  border-color: #cbd5e4;
  color: var(--lok-blue);
  font-size: 9px;
  font-weight: 700;
}
.lok-annotation-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 100001;
  max-width: min(480px, calc(100vw - 32px));
  padding: 10px 14px;
  border-radius: 8px;
  color: #fff;
  background: #17233d;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.25);
  font-size: 11px;
  line-height: 1.5;
  opacity: 0;
  transform: translate(-50%, 12px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.lok-annotation-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.reader-tools [data-lok-action="toggle-panel"].active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--panel2);
}

@media (max-width: 1280px) {
  :root { --lok-panel-width: 320px; }
  .reader-body-shell.lok-annotation-mounted {
    grid-template-columns: 190px minmax(0, 1fr) var(--lok-panel-width);
  }
  .lok-highlight-browser {
    grid-template-columns: 100px minmax(0, 1fr);
  }
}
@media (max-width: 980px) {
  .reader-body-shell.lok-annotation-mounted,
  .reader-hide-toc .reader-body-shell.lok-annotation-mounted {
    grid-template-columns: minmax(0, 1fr);
  }
  .law-reader-dialog .lok-panel-modal {
    position: absolute;
    inset: 0 0 0 auto;
    z-index: 9;
    width: min(380px, 94vw);
    height: 100%;
    border-left: 1px solid var(--lok-border);
    box-shadow: -14px 0 40px rgba(20, 32, 55, 0.2);
  }
  .lok-standalone-shell {
    grid-template-columns: minmax(0, 1fr);
  }
  .lok-panel-standalone {
    position: fixed;
    inset: 60px 0 0 auto;
    z-index: 80;
    width: min(380px, 94vw);
    height: calc(100vh - 60px);
    border-radius: 12px 0 0 0;
    box-shadow: -14px 0 40px rgba(20, 32, 55, 0.2);
  }
}
@media (max-width: 560px) {
  .law-reader-dialog .lok-panel-modal,
  .lok-panel-standalone {
    width: 100vw;
    max-width: none;
  }
  .lok-highlight-browser {
    grid-template-columns: 96px minmax(0, 1fr);
  }
  .lok-color-picker {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .lok-panel-body {
    padding: 8px;
  }
}
