.ticket-toggle {
  z-index: 99;
  background: #fff;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  position: fixed;
  right: 68px;
  bottom: 30px;
  border: 0;
  padding: 0;
  color: #333;
  cursor: pointer;
  border-radius: 5px;
  transition: background 0.2s, right 0.2s;
}

.ticket-toggle.is-corner {
  right: 20px;
}

.ticket-toggle:hover {
  background: #ccc;
}

.ticket-toggle svg {
  display: block;
}

.ticket-toggle__tip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  padding: 4px 8px;
  border-radius: 6px;
  background: #1f2328;
  color: #fff;
  font-size: 12px;
  line-height: 1.4;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}

.ticket-toggle:hover .ticket-toggle__tip,
.ticket-toggle:focus-visible .ticket-toggle__tip {
  opacity: 1;
}

.tk-mask {
  position: fixed;
  inset: 0;
  z-index: 10040;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: rgba(15, 23, 42, 0.45);
}

.tk-mask[hidden] {
  display: none;
}

.tk-dialog {
  width: min(640px, 100%);
  max-height: min(760px, calc(100vh - 48px));
  overflow: auto;
  background: #fff;
  color: #1f2328;
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.22);
  padding: 22px 24px 18px;
  box-sizing: border-box;
}

.tk-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.tk-head h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.3;
  font-weight: 700;
}

.tk-close {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #8b949e;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.tk-close:hover {
  background: #f3f4f6;
  color: #1f2328;
}

.tk-lead {
  margin: 8px 0 16px;
  color: #6b7280;
  font-size: 13px;
  line-height: 1.6;
}

.tk-meta {
  background: #f6f7f9;
  border-radius: 10px;
  padding: 4px 14px;
  margin-bottom: 18px;
}

.tk-meta div {
  display: flex;
  gap: 28px;
  padding: 10px 0;
  font-size: 14px;
}

.tk-meta div + div {
  border-top: 1px solid #eceff3;
}

.tk-meta span {
  flex: 0 0 64px;
  color: #8b949e;
}

.tk-meta b {
  font-weight: 500;
  color: #1f2328;
  word-break: break-all;
}

.tk-label {
  display: block;
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 600;
}

.tk-select,
.tk-editor {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
}

.tk-select {
  width: min(280px, 100%);
  height: 40px;
  padding: 0 12px;
  margin-bottom: 18px;
  color: #1f2328;
  font-size: 14px;
}

.tk-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 8px;
  border-bottom: 1px solid #e5e7eb;
  background: #f7f8fa;
  border-radius: 10px 10px 0 0;
}

.tk-tool {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #4b5563;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tk-tool:hover {
  background: #e8eaee;
}

.tk-toolbar-side {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #9aa1ab;
  font-size: 13px;
}

.tk-preview-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 28px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #6b7280;
  cursor: pointer;
  font-size: 13px;
}

.tk-preview-btn.is-on,
.tk-preview-btn:hover {
  background: #fff;
  color: #1f2328;
  box-shadow: 0 0 0 1px #e5e7eb;
}

.tk-input,
.tk-preview {
  width: 100%;
  min-height: 168px;
  box-sizing: border-box;
  border: 0;
  resize: vertical;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.6;
  color: #1f2328;
  background: transparent;
  outline: none;
  font-family: inherit;
}

.tk-preview {
  display: none;
  overflow: auto;
}

.tk-editor.is-preview .tk-input {
  display: none;
}

.tk-editor.is-preview .tk-preview {
  display: block;
}

.tk-preview code {
  padding: 1px 4px;
  border-radius: 4px;
  background: #f3f4f6;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 13px;
}

.tk-preview a {
  color: #2563eb;
}

.tk-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.tk-btn {
  height: 36px;
  padding: 0 16px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}

.tk-btn--ghost {
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #1f2328;
}

.tk-btn--ghost:hover {
  background: #f7f8fa;
}

.tk-btn--primary {
  border: 0;
  background: #3b82f6;
  color: #fff;
}

.tk-btn--primary:hover {
  background: #2563eb;
}

.tk-error {
  min-height: 18px;
  margin: 8px 0 0;
  color: #dc2626;
  font-size: 13px;
}

.tk-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

.tk-empty {
  padding: 28px 8px;
  text-align: center;
  color: #8b949e;
  font-size: 14px;
}

.tk-item {
  padding: 12px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
}

.tk-item header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
  font-size: 13px;
}

.tk-item strong {
  font-size: 14px;
}

.tk-item time,
.tk-item em {
  color: #8b949e;
  font-style: normal;
}

.tk-item p {
  margin: 0;
  color: #374151;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.theme--dark .tk-dialog {
  background: #21262d;
  color: #f1f5ff;
}

.theme--dark .tk-close:hover,
.theme--dark .tk-tool:hover,
.theme--dark .tk-btn--ghost:hover {
  background: #2a313a;
  color: #f1f5ff;
}

.theme--dark .tk-lead,
.theme--dark .tk-meta span,
.theme--dark .tk-toolbar-side,
.theme--dark .tk-empty,
.theme--dark .tk-item time,
.theme--dark .tk-item em {
  color: #9aa4b2;
}

.theme--dark .tk-meta,
.theme--dark .tk-toolbar {
  background: #161b22;
}

.theme--dark .tk-meta b,
.theme--dark .tk-item p,
.theme--dark .tk-select,
.theme--dark .tk-input,
.theme--dark .tk-preview {
  color: #f1f5ff;
}

.theme--dark .tk-select,
.theme--dark .tk-editor,
.theme--dark .tk-item,
.theme--dark .tk-btn--ghost {
  background: #0d1117;
  border-color: #3c4450;
  color: #f1f5ff;
}

.theme--dark .tk-meta div + div,
.theme--dark .tk-toolbar {
  border-color: #3c4450;
}

.theme--dark .tk-preview code {
  background: #2a313a;
}

@media print {
  .ticket-toggle,
  .tk-mask {
    display: none !important;
  }
}
