@font-face {
  font-family: "SimBraille";
  src: url("https://hurthuang.github.io/vi.note/brl/Mix-Trans/SIMBRL.TTF")
    format("truetype");
}

:root {
  color-scheme: light dark;
  --page-background: #f5f3ee;
  --surface: #fcfbf7;
  --surface-muted: #f0ede6;
  --surface-strong: #ebe7de;
  --text-primary: #1d1c19;
  --text-secondary: #57524a;
  --border-subtle: #d2ccc2;
  --border-strong: #7d776e;
  --accent: #24211b;
  --accent-contrast: #fffdf8;
  --focus-ring: #111;
  --link: #3d3a34;
  --link-hover: #000;
  --candidate-highlight: #dfebe4;
  --marking: #e4efeb;
  --danger: #7a1f1f;
  --syntax-comment: #6e7681;
  --syntax-phrase: #204f93;
  --syntax-separator: #8f6f2f;
  --syntax-hyphen: #0057b8;
  --syntax-reading-bpmf: #a73f09;
  --syntax-reading-latin: #0f7a5c;
  --syntax-error: #a32121;
  --syntax-error-background: rgba(163, 33, 33, 0.1);
  --syntax-selection: rgba(209, 148, 66, 0.28);
  --shadow-flat: none;
  --radius-sm: 6px;
  --radius-md: 12px;
  --spacing-1: 0.375rem;
  --spacing-2: 0.75rem;
  --spacing-3: 1rem;
  --spacing-4: 1.5rem;
  --spacing-5: 2rem;
  --panel-min-height: 37rem;
}

html,
body {
  margin: 0;
  background: var(--page-background);
  color: var(--text-primary);
  font-family: "Iansui", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei",
    system-ui, sans-serif;
  font-size: 14pt;
  line-height: 1.55;
  overflow: auto;
}

body {
  padding: var(--spacing-3);
}

a {
  color: var(--link);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.14em;
}

a:hover {
  color: var(--link-hover);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

hr {
  border: 0;
  border-top: 1px solid var(--border-subtle);
  margin: var(--spacing-3) 0;
}

.main {
  max-width: 1320px;
  margin-left: auto;
  margin-right: auto;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-2);
  overflow: hidden;
}

#loading {
  position: absolute;
  top: var(--spacing-2);
  left: var(--spacing-3);
  display: block;
  margin: 0;
  max-width: fit-content;
  padding: var(--spacing-2) var(--spacing-3);
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-flat);
}

.navi h1 {
  font-size: 11pt;
  display: inline;
}

.navi {
  margin: 0;
  padding: var(--spacing-2) var(--spacing-3);
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: 11pt;
  line-height: 1.75;
  -moz-user-select: -moz-none;
  -khtml-user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

.navi a {
  color: var(--text-secondary);
  text-decoration: none;
}

.navi a:hover {
  color: var(--text-primary);
}

.content {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.feature {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--spacing-3);
  min-height: 0;
}

.left,
.right {
  width: 100%;
  overflow: auto !important;
  min-height: 0;
}

.right {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--spacing-3);
  box-sizing: border-box;
}

.right h2,
.right h3 {
  margin-top: 0;
  margin-bottom: var(--spacing-2);
  font-weight: 600;
}

.right table {
  width: 100%;
  font-size: 11pt;
  border-collapse: collapse;
}

.right table td {
  padding: var(--spacing-1) 0;
}

.right table td:first-child {
  width: 25%;
}

.right table td:last-child {
  width: 75%;
}

.right p,
.right li,
.right small {
  color: var(--text-secondary);
  font-size: 10.5pt;
}

.right p,
.right ul,
.right ol {
  margin-top: 0;
  margin-bottom: var(--spacing-2);
}

.right details {
  border-top: 1px solid var(--border-subtle);
  padding-top: var(--spacing-2);
  margin-top: var(--spacing-2);
}

.right details:first-of-type {
  border-top: 0;
  padding-top: 0;
  margin-top: 0;
}

.right summary {
  cursor: pointer;
  list-style: none;
  color: var(--text-primary);
  font-weight: 600;
  margin-bottom: var(--spacing-1);
}

.right summary::-webkit-details-marker {
  display: none;
}

.right summary::before {
  content: "+";
  display: inline-block;
  width: 1.2em;
  color: var(--text-secondary);
}

.right details[open] summary::before {
  content: "−";
}

.right select,
.right input[type="text"],
.right input[type="button"],
.right button {
  font: inherit;
}

.right select,
input[type="button"],
button {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-primary);
}

.right select {
  min-width: 60%;
  padding: 0.2rem 0.55rem;
}

input[type="button"],
button {
  cursor: pointer;
}

input[type="button"]:hover,
button:hover {
  background: var(--surface-muted);
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--accent);
}

.option_title {
  width: 25%;
  text-align: right;
  vertical-align: top;
  white-space: nowrap;
  color: var(--text-primary);
  padding-right: var(--spacing-2);
}

#edit_area {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: var(--panel-min-height);
  height: 100%;
  overflow: auto !important;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: var(--spacing-2);
  box-sizing: border-box;
}

.status_area {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--spacing-2);
  margin-bottom: var(--spacing-2);
  padding-bottom: var(--spacing-2);
  border-bottom: 1px solid var(--border-subtle);
}

#status {
  min-width: 100px;
  font-size: 11pt;
  font-weight: 600;
  letter-spacing: 0.04em;
}

#status a,
#menu_visible a {
  color: inherit;
  text-decoration: none;
}

#menu_visible {
  flex-grow: 1;
  font-size: 10pt;
  color: var(--text-secondary);
  text-align: right;
  white-space: nowrap;
  padding-right: 0;
}

textarea {
  width: 100%;
  padding: 0.8rem 0.9rem;
  box-sizing: border-box;
  resize: none;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 14pt;
}

textarea:focus {
  border-color: var(--border-strong);
  outline: none;
}

textarea#text_area {
  flex-grow: 1;
  margin: 0;
  width: 100%;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-primary);
  font-family: "Iansui", "Noto Sans TC", "PingFang TC", sans-serif;
  font-size: 18px;
  line-height: 1.2em;
  ime-mode: disabled;
  -webkit-ime-mode: disabled;
  -moz-ime-mode: disabled;
  -ms-ime-mode: disabled;
}

textarea#text_area::placeholder {
  color: var(--text-secondary);
}

textarea#text_area:focus {
  border: 0;
  outline: none;
}

textarea#text_area:focus ~ * #edit_area,
#edit_area:has(textarea#text_area:focus) {
  border-color: var(--focus-ring);
}

textarea#feature_user_phrases_text_area,
textarea#feature_excluded_phrases_text_area {
  height: 70%;
}

.syntax-highlight-field {
  position: relative;
  width: 100%;
}

.syntax-highlight-field--tall {
  height: 70%;
}

.syntax-highlight-field--fill {
  flex: 1 1 auto;
  min-height: 0;
}

.syntax-highlight-input {
  position: relative;
  z-index: 1;
  background: transparent;
  color: transparent;
  caret-color: var(--text-primary);
}

.syntax-highlight-input::selection {
  color: transparent;
  background: var(--syntax-selection);
}

.syntax-highlight-input::placeholder {
  color: var(--text-secondary);
}

.syntax-highlight-backdrop {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-primary);
}

.syntax-highlight-content {
  margin: 0;
  padding: 0.8rem 0.9rem;
  min-height: 100%;
  box-sizing: border-box;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.syntax-token-comment {
  color: var(--syntax-comment);
}

.syntax-token-phrase {
  color: var(--syntax-phrase);
  font-weight: 600;
}

.syntax-token-separator,
.syntax-token-separator-space {
  color: var(--syntax-separator);
}

.syntax-token-separator-hyphen {
  color: var(--syntax-hyphen);
}

.syntax-token-reading-bpmf {
  color: var(--syntax-reading-bpmf);
}

.syntax-token-reading-latin {
  color: var(--syntax-reading-latin);
}

.syntax-token-error {
  color: var(--syntax-error);
  background: var(--syntax-error-background);
}

#function {
  position: absolute;
  padding: var(--spacing-2) 0 0 var(--spacing-2);
  color: var(--text-primary);
}

#composing_buffer p {
  display: inline-block;
  margin-top: -0.25rem;
  margin-bottom: var(--spacing-2);
  padding: 0.35rem 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14pt;
}

#candidates {
  float: left;
  padding: 0.25rem 0.4rem;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-flat);
  color: var(--text-primary);
}

#candidates td {
  color: var(--text-primary);
  font-size: 12pt;
  padding: 2px 2px;
}

.page_info {
  font-size: 10pt;
  color: var(--text-secondary);
  text-align: right;
}

#tooltip {
  float: left;
  padding: 0.35rem 0.6rem;
  background: var(--surface-strong);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-flat);
}

.cursor {
  color: var(--danger);
  animation: blink 0.9s step-end infinite;
}

.marking {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  background: var(--marking);
}

.highlighted_candidate {
  background: var(--candidate-highlight);
  font-weight: 700;
}

.keyCap {
  padding: 4px 10px !important;
  font-size: 10pt;
  color: var(--text-secondary);
}

.candidate {
  padding: 4px 10px 4px 0 !important;
  font-size: 12pt !important;
}

#dump_area {
  margin: 10px 0;
  font-size: 10pt;
}

#dump_area ul li {
  list-style-type: decimal;
}

div#feature_input {
  -moz-user-select: -moz-none;
  -khtml-user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

div#feature_user_phrases,
div#feature_text_to_braille,
div#feature_braille_to_text,
div#feature_add_bpmf,
div#feature_convert_hanyupnyin {
  display: none;
}

div.text_to_braille_output,
div.braille_to_text_output {
  width: 100%;
  max-width: 100%;
}

blockquote {
  margin: var(--spacing-2) 0;
  padding: var(--spacing-3);
  background: var(--surface-muted);
  border-left: 3px solid var(--border-strong);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.credit {
  margin: 0;
  padding: 0 var(--spacing-1);
  font-size: 10pt;
  color: var(--text-secondary);
}

.phrase_generate {
  display: flex;
  flex-direction: row;
  gap: var(--spacing-2);
  height: 100%;
}

.phrase_generate_input_output_container {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  width: 50%;
}

.phrase_generate_input_output_container textarea {
  height: 100%;
  box-sizing: border-box;
}

.vcard_import_panel {
  margin-top: var(--spacing-3);
  padding: var(--spacing-3);
  background: var(--surface-muted);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.vcard_import_panel h3 {
  margin-top: 0;
  margin-bottom: var(--spacing-2);
  font-size: 1rem;
}

.vcard_drop_zone {
  padding: var(--spacing-4);
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  text-align: center;
  transition:
    border-color 0.2s ease,
    background-color 0.2s ease,
    color 0.2s ease;
}

.vcard_drop_zone.is-dragover {
  border-color: var(--focus-ring);
  background: var(--surface-strong);
  color: var(--text-primary);
}

.vcard_import_status {
  margin-bottom: 0;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.vcard_services_table {
  width: 100% !important;
  border-collapse: collapse !important;
  margin-top: var(--spacing-3);
  margin-bottom: var(--spacing-3);
  font-size: 10pt !important;
}

.vcard_services_table th,
.vcard_services_table td {
  padding: var(--spacing-2) var(--spacing-2) !important;
  text-align: left !important;
  border-bottom: 1px solid var(--border-subtle) !important;
  width: auto !important;
}

.vcard_services_table th {
  font-weight: 600;
  color: var(--text-primary);
  background: var(--surface-strong);
  border-bottom: 2px solid var(--border-strong) !important;
}

.vcard_services_table td {
  color: var(--text-secondary);
  vertical-align: middle;
}

.vcard_services_table tr {
  transition: background-color 0.2s ease;
}

.vcard_services_table tr:hover {
  background: var(--surface-strong);
}


.simple-keyboard {
  min-height: 230px;
  margin-top: var(--spacing-2);
  padding: 5;
  background: var(--surface-muted);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.hg-theme-default {
  background: transparent;
}

.hg-button {
  color: var(--text-primary) !important;
  background: var(--surface) !important;
  border: 1px solid var(--border-subtle) !important;
  box-shadow: none !important;
}

.hg-standardBtn {
  font-size: 12pt;
}

.hg-button[data-skbtn="{ctrl}"] {
  flex-grow: 1 !important;
  max-width: 80px;
}

.hg-button-active {
  background: var(--accent) !important;
  color: var(--accent-contrast) !important;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

@media (max-width: 767px) {
  body {
    padding: var(--spacing-2);
  }

  .right {
    padding: var(--spacing-2);
  }

  #edit_area {
    min-height: 28rem;
  }

  .phrase_generate {
    flex-direction: column;
  }

  .phrase_generate_input_output_container {
    width: 100%;
  }

  .option_title {
    width: auto;
    text-align: left;
    display: block;
    padding-right: 0;
  }
}

@media (min-width: 768px) {
  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  .main {
    height: calc(100dvh - (var(--spacing-3) * 2));
    max-height: calc(100dvh - (var(--spacing-3) * 2));
  }

  .feature {
    flex-direction: row;
    flex-wrap: nowrap;
    min-height: 80%;
    height: 100%;
  }

  .left {
    width: 70%;
    overflow: auto !important;
  }

  .right {
    width: 30%;
    overflow: auto !important;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --page-background: #111311;
    --surface: #181b18;
    --surface-muted: #202420;
    --surface-strong: #272c27;
    --text-primary: #f2f0ea;
    --text-secondary: #c2bdb1;
    --border-subtle: #42473f;
    --border-strong: #8f978b;
    --accent: #f2f0ea;
    --accent-contrast: #141613;
    --focus-ring: #f2f0ea;
    --link: #d6d1c6;
    --link-hover: #fffdf8;
    --candidate-highlight: #2e3a31;
    --marking: #2d3830;
    --danger: #ff7f7f;
    --syntax-comment: #98a1ad;
    --syntax-phrase: #93c5fd;
    --syntax-separator: #d6ba6a;
    --syntax-hyphen: #7dd3fc;
    --syntax-reading-bpmf: #ffb27d;
    --syntax-reading-latin: #7ed7b7;
    --syntax-error: #ff8f8f;
    --syntax-error-background: rgba(255, 143, 143, 0.14);
    --syntax-selection: rgba(214, 186, 106, 0.36);
  }

  textarea {
    caret-color: var(--text-primary);
  }
}

@media (forced-colors: active) {
  :root {
    --shadow-flat: none;
  }

  a,
  button,
  input,
  select,
  summary,
  textarea {
    forced-color-adjust: auto;
  }

  .cursor {
    animation: none;
  }
}

input [type="button"],
button {
  /* background: var(--surface) !important; */
  font-size: 14pt !important;
  padding: 5px;
}

/* input [type="button"]:hover,
button:hover {
  border-width: 2px !important;
} */

#graph_walk_result {
  display: none;
  margin-bottom: 8px;
}

#graph_walk_result > div {
  display: flex;
  gap: 8px;
  align-items: center;
}

#graph_result_text {
  flex: 1;
  padding: 6px 10px;
  font-size: 1.1em;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  color: var(--text-primary);
  cursor: default;
}

#graph_result_score {
  width: 100px;
  text-align: center;
  padding: 6px 10px;
  font-size: 1.1em;
  font-family: monospace;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  color: var(--text-secondary);
  cursor: default;
}

#mermaid_graph_container {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: var(--spacing-3);
  overflow: auto;
  min-height: 300px;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

#mermaid_graph_actions {
  position: absolute;
  top: var(--spacing-2);
  right: var(--spacing-2);
  display: flex;
  gap: var(--spacing-2);
  z-index: 10;
}

#mermaid_graph_actions button {
  font-size: 10pt !important;
  padding: 4px 8px;
  opacity: 0.7;
  transition: opacity 0.2s;
}

#mermaid_graph_actions button:hover {
  opacity: 1;
}

#mermaid_graph_output {
  width: 100%;
  display: flex;
  justify-content: center;
}


#keyhandle_time {
  font-size: 10pt;
  color: var(--text-secondary);
}