.tmf-wrap {
  --tmf-accent: #6b2e1f;
  --tmf-border: #d6d3cf;
  --tmf-muted: #5f5a55;
  --tmf-bg: #fff;
  --tmf-soft: #faf7f4;
  max-width: 820px;
  margin: 2rem auto;
  color: inherit;
  font-size: 16px;
  line-height: 1.55;
}
.tmf-wrap *, .tmf-wrap *::before, .tmf-wrap *::after { box-sizing: border-box; }
.tmf-title { margin: 0 0 .4rem; color: var(--tmf-accent); }
.tmf-intro { margin: 0 0 1.5rem; color: var(--tmf-muted); }

.tmf-section {
  border: 1px solid var(--tmf-border);
  border-radius: 10px;
  background: var(--tmf-bg);
  padding: 1.25rem 1.25rem .5rem;
  margin: 0 0 1.25rem;
}
.tmf-section legend {
  font-weight: 700;
  padding: 0 .5rem;
  color: var(--tmf-accent);
}
.tmf-note { margin: 0 0 1rem; color: var(--tmf-muted); font-size: .92em; }

.tmf-field { margin: 0 0 1rem; }
.tmf-field label { display: block; font-weight: 600; margin: 0 0 .35rem; }
.tmf-field input[type=text],
.tmf-field input[type=email],
.tmf-field select,
.tmf-field textarea {
  width: 100%;
  padding: .65rem .75rem;
  border: 1px solid #b9b4ae;
  border-radius: 6px;
  background: #fff;
  color: #1d1b19;
  font: inherit;
}
.tmf-field textarea { resize: vertical; min-height: 5.5rem; }
.tmf-field input:focus, .tmf-field select:focus, .tmf-field textarea:focus {
  outline: 2px solid var(--tmf-accent);
  outline-offset: 1px;
  border-color: var(--tmf-accent);
}
.tmf-field [lang="ta"] { font-family: "Latha", "Nirmala UI", "Noto Sans Tamil", "FreeSerif", inherit; }
.tmf-field input[type=file] { font: inherit; }
.tmf-help { margin: .3rem 0 0; font-size: .88em; color: var(--tmf-muted); }
.tmf-count { font-variant-numeric: tabular-nums; }
.tmf-req { color: #b3261e; }
.tmf-invalid { border-color: #b3261e !important; background: #fff6f5 !important; }

.tmf-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 640px) { .tmf-row { grid-template-columns: 1fr; gap: 0; } }

.tmf-symbols { display: flex; flex-wrap: wrap; gap: .3rem; margin: 0 0 .35rem; }
.tmf-sym {
  min-width: 2.25rem;
  min-height: 2.25rem;
  padding: .1rem .5rem;
  border: 1px solid var(--tmf-border);
  border-radius: 4px;
  background: var(--tmf-soft);
  color: #1d1b19;
  font: inherit;
  font-size: 1.35em;
  line-height: 1;
  cursor: pointer;
}
.tmf-sym:hover, .tmf-sym:focus { border-color: var(--tmf-accent); }

.tmf-consent {
  padding: 1rem;
  border-radius: 8px;
  background: var(--tmf-soft);
  border: 1px solid var(--tmf-border);
  margin: 0 0 1rem;
}
.tmf-consent label { display: flex; gap: .6rem; align-items: flex-start; font-weight: 400; }
.tmf-consent input { margin-top: .3rem; flex: none; }
.tmf-consent input.tmf-invalid { outline: 2px solid #b3261e; }

.tmf-actions { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }
.tmf-submit, .tmf-download {
  display: inline-block;
  padding: .75rem 1.3rem;
  border: 0;
  border-radius: 6px;
  background: var(--tmf-accent);
  color: #fff !important;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.tmf-submit:hover, .tmf-download:hover { filter: brightness(1.12); }
.tmf-submit:disabled { opacity: .6; cursor: progress; }
.tmf-clear {
  display: inline-block;
  text-decoration: none;
  padding: .7rem 1rem;
  border: 1px solid var(--tmf-border);
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.tmf-draft-status { font-size: .85em; color: var(--tmf-muted); }

.tmf-message { margin: 1rem 0 .5rem; min-height: 1.2em; }
.tmf-message.tmf-error { color: #b3261e; font-weight: 600; }
.tmf-message.tmf-success { color: #1e6b34; font-weight: 600; }
.tmf-result { margin: .5rem 0 0; }

.tmf-hp { position: absolute !important; left: -10000px !important; width: 1px; height: 1px; overflow: hidden; }

.tmf-form[hidden] { display: none !important; }

/* ---- Article ID box (after submitting) --------------------------------- */
.tmf-idbox {
  border: 2px solid var(--tmf-accent);
  border-radius: 10px;
  background: var(--tmf-soft);
  padding: 1.25rem;
  margin: .5rem 0 1rem;
}
.tmf-idbox-label { font-size: .85em; text-transform: uppercase; letter-spacing: .06em; color: var(--tmf-muted); }
.tmf-idbox-row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin: .35rem 0 1rem; }
.tmf-idbox-code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 1.6em;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--tmf-accent);
  background: transparent;
  padding: 0;
}

/* ---- Status badges (front end + admin share names) --------------------- */
.tmf-badge {
  display: inline-block;
  padding: .15em .65em;
  border-radius: 999px;
  font-size: .8em;
  font-weight: 700;
  line-height: 1.5;
  white-space: nowrap;
  vertical-align: middle;
  border: 1px solid transparent;
}
.tmf-badge--submitted    { background: #e8eef7; color: #1f3f6e; border-color: #c4d3ea; }
.tmf-badge--under_review { background: #fdf2dc; color: #7a4d00; border-color: #f0d49a; }
.tmf-badge--rejected     { background: #fbe7e6; color: #9b1c14; border-color: #f0bdb9; }
.tmf-badge--published    { background: #e3f3e7; color: #1c6331; border-color: #b6dcc0; }
.tmf-badge--revision_required  { background: #fdeadb; color: #8a3b00; border-color: #f2c29b; }
.tmf-badge--revision_submitted { background: #eee8f7; color: #4b2d7a; border-color: #d3c4ea; }
.tmf-badge--accepted           { background: #dff2ef; color: #0f5a50; border-color: #aedbd3; }
.tmf-badge--copyediting        { background: #e6f0f7; color: #1d4e6e; border-color: #bcd5e8; }
.tmf-badge--production         { background: #e6f0f7; color: #1d4e6e; border-color: #bcd5e8; }
.tmf-badge--scheduled          { background: #edf5e0; color: #3d5a12; border-color: #cfe2ad; }

/* ---- Tracking page ----------------------------------------------------- */
.tmf-track-form { margin: 0 0 1rem; }
.tmf-track-form input#tmf-track-id { text-transform: uppercase; font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .03em; }
.tmf-track-card {
  border: 1px solid var(--tmf-border);
  border-radius: 12px;
  background: var(--tmf-bg);
  padding: 1.25rem 1.25rem .75rem;
  outline: none;
}
.tmf-track-head { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; }
.tmf-track-id { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; color: var(--tmf-accent); letter-spacing: .03em; }
.tmf-track-title { margin: .6rem 0 .2rem; font-size: 1.3em; line-height: 1.3; }
.tmf-track-alt { margin: 0 0 .3rem; font-family: "Latha", "Nirmala UI", "Noto Sans Tamil", "FreeSerif", inherit; }
.tmf-track-meta { margin: .3rem 0 1rem; color: var(--tmf-muted); font-size: .92em; }

.tmf-steps { list-style: none; display: flex; margin: 0 0 1rem; padding: 0; counter-reset: none; }
.tmf-step { flex: 1; position: relative; text-align: center; font-size: .9em; color: var(--tmf-muted); }
.tmf-step::before {
  content: ""; position: absolute; top: 1rem; left: -50%; width: 100%; height: 3px; background: var(--tmf-border); z-index: 0;
}
.tmf-step:first-child::before { display: none; }
.tmf-step.done::before, .tmf-step.current::before { background: var(--tmf-accent); }
.tmf-step-dot {
  position: relative; z-index: 1;
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; border-radius: 50%;
  background: #fff; border: 3px solid var(--tmf-border); font-weight: 700; color: var(--tmf-muted);
}
.tmf-step-label { display: block; margin-top: .3rem; }
.tmf-step.done .tmf-step-dot { background: var(--tmf-accent); border-color: var(--tmf-accent); color: #fff; }
.tmf-step.current .tmf-step-dot { border-color: var(--tmf-accent); color: var(--tmf-accent); }
.tmf-step.current .tmf-step-label { color: inherit; font-weight: 700; }
.tmf-step.rejected .tmf-step-dot { background: #b3261e; border-color: #b3261e; color: #fff; }
.tmf-step.rejected::before { background: #b3261e; }

.tmf-track-explain { margin: 0 0 1rem; padding: .75rem 1rem; background: var(--tmf-soft); border-radius: 8px; }
.tmf-track-section { border-top: 1px solid var(--tmf-border); padding-top: .75rem; margin-top: 1rem; }
.tmf-track-section h4 { margin: 0 0 .6rem; font-size: 1em; color: var(--tmf-accent); }

.tmf-comments { list-style: none; margin: 0; padding: 0; }
.tmf-comment { border-left: 3px solid var(--tmf-accent); background: var(--tmf-soft); padding: .7rem .9rem; border-radius: 0 8px 8px 0; margin: 0 0 .75rem; }
.tmf-comment-head { display: flex; justify-content: space-between; gap: .5rem; flex-wrap: wrap; font-size: .92em; }
.tmf-comment-head span { color: var(--tmf-muted); }
.tmf-comment-body { margin-top: .35rem; overflow-wrap: anywhere; }

.tmf-history { list-style: none; margin: 0; padding: 0; }
.tmf-history li { padding: .4rem 0; border-bottom: 1px dashed var(--tmf-border); }
.tmf-history li:last-child { border-bottom: 0; }
.tmf-history-date { display: inline-block; min-width: 7.5rem; color: var(--tmf-muted); font-size: .9em; }
.tmf-history-note { margin: .3rem 0 0 0; font-size: .95em; overflow-wrap: anywhere; }
.tmf-track-foot { margin: 1rem 0 .25rem; font-size: .92em; }
.tmf-track-foot a { color: var(--tmf-accent); }

@media (max-width: 520px) {
  .tmf-step-label { font-size: .8em; }
  .tmf-history-date { display: block; }
}

/* ---- Rich-text editor (manuscript body) ------------------------------- */
.tmf-editor {
  border: 1px solid #b9b4ae;
  border-radius: 6px;
  background: #fff;
  color: #1d1b19;
}
.tmf-editor.is-focused { outline: 2px solid var(--tmf-accent); outline-offset: 1px; border-color: var(--tmf-accent); }
.tmf-editor.tmf-invalid { border-color: #b3261e; background: #fff6f5; }
.tmf-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border-bottom: 1px solid var(--tmf-border);
  background: var(--tmf-soft);
  border-radius: 6px 6px 0 0;
  position: sticky;
  top: 0;
  z-index: 2;
}
.tmf-tb {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.1rem;
  height: 2.1rem;
  padding: 0 .4rem;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: #1d1b19;
  font: inherit;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}
.tmf-tb:hover { background: #fff; border-color: var(--tmf-border); }
.tmf-tb:focus-visible { outline: 2px solid var(--tmf-accent); outline-offset: 1px; }
.tmf-tb[aria-pressed="true"] { background: #fff; border-color: var(--tmf-accent); color: var(--tmf-accent); }
.tmf-tb svg { width: 1.15rem; height: 1.15rem; fill: currentColor; }
.tmf-tb sup, .tmf-tb sub { font-size: .68em; vertical-align: baseline; position: relative; line-height: 0; }
.tmf-tb sup { top: -.55em; }
.tmf-tb sub { top: .35em; }
.tmf-tb-h { font-weight: 700; font-family: Georgia, serif; }
.tmf-tb-sep { width: 1px; align-self: stretch; margin: 4px 3px; background: var(--tmf-border); }

.tmf-editor-area {
  position: relative;
  min-height: 9rem;
  max-height: 65vh;
  overflow-y: auto;
  padding: .7rem .85rem;
  line-height: 1.6;
  outline: none;
  overflow-wrap: anywhere;
  resize: vertical;
}
.tmf-editor.is-empty .tmf-editor-area::before {
  content: attr(data-placeholder);
  color: #8a847d;
  pointer-events: none;
  position: absolute;
}
.tmf-editor-area[lang="ta"] { font-family: "Latha", "Nirmala UI", "Noto Sans Tamil", "FreeSerif", inherit; }
.tmf-editor-area p { margin: 0 0 .7em; }
.tmf-editor-area h3 { font-size: 1.1em; margin: .9em 0 .4em; }
.tmf-editor-area h4 { font-size: 1em; font-style: italic; margin: .8em 0 .35em; }
.tmf-editor-area ul, .tmf-editor-area ol { margin: 0 0 .7em 1.6em; padding: 0; }
.tmf-editor-area ul { list-style: disc; }
.tmf-editor-area ol { list-style: decimal; }
.tmf-editor-area ul ul { list-style: circle; }
.tmf-editor-area ol ol { list-style: lower-alpha; }
.tmf-editor-area li { margin: 0 0 .25em; }
.tmf-editor-area blockquote { margin: 0 0 .7em; padding: .2em .9em; border-left: 3px solid var(--tmf-accent); font-style: italic; color: #3c3834; }
.tmf-editor-area sup, .tmf-editor-area sub { font-size: .75em; line-height: 0; }
.tmf-track-sub { margin: -.1rem 0 .3rem; font-size: .92em; color: var(--tmf-muted); font-style: italic; }
.tmf-track-alt.tmf-track-sub { font-style: normal; }
/* Article content: headings, tables and figures with automatic numbering (3.6) */
.tmf-article-content { counter-reset: tmftab tmffig; }
.tmf-article-content h2 { font-size: 1.2em; margin: 1.1em 0 .45em; }
.tmf-article-content h3 { font-size: 1.07em; margin: .95em 0 .4em; }
.tmf-article-content h4 { font-size: 1em; font-style: italic; margin: .8em 0 .35em; }
.tmf-article-content table { counter-increment: tmftab; border-collapse: collapse; width: 100%; margin: 1em 0 1.2em; font-size: .93em; }
.tmf-article-content caption { caption-side: top; text-align: center; font-size: .92em; padding: 0 0 .4em; }
.tmf-article-content caption::before { content: "Table " counter(tmftab) ". "; font-weight: 700; }
.tmf-article-content th, .tmf-article-content td { border: 1px solid #9c968f; padding: .35em .5em; vertical-align: top; min-width: 2.5em; }
.tmf-article-content th { background: #efeae6; font-weight: 700; text-align: center; }
.tmf-article-content td p, .tmf-article-content th p { margin: 0 0 .3em; }
.tmf-article-content figure { counter-increment: tmffig; margin: 1em auto 1.2em; text-align: center; }
.tmf-article-content figure img { max-width: 100%; height: auto; display: block; margin: 0 auto .4em; }
.tmf-article-content figcaption { font-size: .92em; }
.tmf-article-content figcaption::before { content: "Fig. " counter(tmffig) ". "; font-weight: 700; }
.tmf-article-content blockquote { margin: 0 0 .7em; padding: .2em .9em; border-left: 3px solid var(--tmf-accent, #6b2e1f); font-style: italic; }
.tmf-article-content a { color: #0b57a4; }

/* Full article editor (3.6) ------------------------------------------------ */
.tmf-editor--full .tmf-editor-area { min-height: 26rem; max-height: 75vh; padding: 1rem 1.2rem; font-family: Georgia, "Times New Roman", "Latha", "Nirmala UI", serif; }
.tmf-ed-tabs { display: flex; justify-content: flex-end; gap: 2px; padding: 4px 6px 0; background: #f3f0ec; border-bottom: 0; border-radius: 6px 6px 0 0; }
.tmf-ed-tab { font: inherit; font-size: .85em; padding: .3rem .8rem; border: 1px solid transparent; border-bottom: 0; border-radius: 5px 5px 0 0; background: transparent; color: #5f5a55; cursor: pointer; }
.tmf-ed-tab[aria-selected="true"] { background: #faf8f6; border-color: #d6d3cf; color: #1d1b19; font-weight: 600; }
.tmf-ed-tab:focus-visible { outline: 2px solid var(--tmf-accent); outline-offset: 1px; }
.tmf-editor--full .tmf-toolbar { position: sticky; top: 0; z-index: 3; }
.tmf-toolbar.is-disabled .tmf-tb, .tmf-toolbar.is-disabled select { opacity: .35; pointer-events: none; }
.tmf-tb-select { font: inherit; font-size: .85em; height: 2rem; padding: 0 .4rem; border: 1px solid transparent; border-radius: 4px; background: #fff; color: #1d1b19; max-width: 11rem; }
.tmf-tb-select:focus-visible { outline: 2px solid var(--tmf-accent); outline-offset: 1px; }
.tmf-tb-label { font-size: .82em; margin-left: .25rem; }
.tmf-tb-table, .tmf-tb-figure { width: auto !important; padding: 0 .45rem !important; }
.tmf-ctxbar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 5px 8px; background: #fbf4e6; border-bottom: 1px solid #efdcb4; font-size: .82em; }
.tmf-ctxbar[hidden] { display: none; }
.tmf-ctx-label { font-weight: 700; color: #6b4a12; margin-right: .2rem; }
.tmf-ctx { font: inherit; padding: .2rem .55rem; border: 1px solid #d9c49b; border-radius: 4px; background: #fff; cursor: pointer; color: #3a2e1a; }
.tmf-ctx:hover { border-color: var(--tmf-accent); }
.tmf-ctx:focus-visible { outline: 2px solid var(--tmf-accent); outline-offset: 1px; }
.tmf-ctx-delTable, .tmf-ctx-delFigure { color: #9b1c14; }
.tmf-editor-area h2 { font-size: 1.2em; }
.tmf-editor-area table { table-layout: fixed; }
.tmf-editor-area td, .tmf-editor-area th, .tmf-editor-area caption { outline: none; }
.tmf-editor-area td:focus-within, .tmf-editor-area th:focus-within { box-shadow: inset 0 0 0 2px #e6b85c; }
.tmf-editor-area caption:empty::after, .tmf-editor-area caption:has(> br:only-child)::after { content: "Type a caption…"; color: #8a847d; font-style: italic; }
.tmf-editor-area figure { position: relative; padding: .4rem; border: 1px dashed transparent; border-radius: 4px; cursor: default; }
.tmf-editor-area figure:hover { border-color: #d6d3cf; }
.tmf-editor-area figure.is-selected { border-color: var(--tmf-accent); box-shadow: 0 0 0 2px rgba(107, 46, 31, .2); }
.tmf-editor-area figure img { cursor: pointer; max-height: 28rem; object-fit: contain; }
.tmf-editor-area figcaption { outline: none; min-height: 1.4em; cursor: text; }
.tmf-editor-area figcaption:empty::after { content: attr(data-placeholder); color: #8a847d; font-style: italic; }
.tmf-editor-source { display: block; width: 100%; min-height: 26rem; max-height: 75vh; border: 0; border-top: 1px solid #e6e2dd; padding: .9rem 1rem; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; resize: vertical; background: #fffdf9; color: #1d1b19; }
.tmf-editor-source:focus { outline: 2px solid var(--tmf-accent); outline-offset: -2px; }
.tmf-editor-status { font-size: .82em; color: #6b4a12; padding: 0 .8rem; min-height: 0; }
.tmf-editor-status:not(:empty) { padding: .35rem .8rem; background: #fbf4e6; border-top: 1px solid #efdcb4; }
.tmf-editor.is-fullscreen { position: fixed; inset: 0; z-index: 100000; border-radius: 0; display: flex; flex-direction: column; background: #fff; }
.tmf-editor.is-fullscreen .tmf-editor-area, .tmf-editor.is-fullscreen .tmf-editor-source { flex: 1; max-height: none; min-height: 0; }
.tmf-editor.is-fullscreen .tmf-editor-area { padding: 1.5rem max(1.2rem, calc(50vw - 26rem)); }
html.tmf-noscroll, html.tmf-noscroll body { overflow: hidden; }

/* Editor dialogs */
.tmf-dialog { border: 0; border-radius: 10px; padding: 0; width: min(30rem, calc(100vw - 2rem)); box-shadow: 0 12px 40px rgba(0,0,0,.25); color: #1d1b19; font-family: inherit; }
.tmf-dialog::backdrop { background: rgba(20, 16, 12, .45); }
.tmf-dialog-form { padding: 1.1rem 1.2rem 1rem; margin: 0; }
.tmf-dialog-title { margin: 0 0 .8rem; font-size: 1.1em; color: var(--tmf-accent, #6b2e1f); }
.tmf-dialog p { margin: 0 0 .75rem; }
.tmf-dialog label { display: block; font-weight: 600; font-size: .92em; margin-bottom: .25rem; }
.tmf-dialog label input[type="checkbox"] { margin-right: .35rem; }
.tmf-dialog input[type="text"], .tmf-dialog input[type="url"], .tmf-dialog input[type="number"] { width: 100%; box-sizing: border-box; padding: .5rem .6rem; border: 1px solid #b9b4ae; border-radius: 5px; font: inherit; }
.tmf-dialog input[type="file"] { width: 100%; }
.tmf-dialog-row { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.tmf-dialog-hint { font-weight: 400; color: #6b665f; }
.tmf-dialog-note { font-size: .84em; color: #6b665f; }
.tmf-dialog-error { color: #9b1c14; font-weight: 600; font-size: .9em; }
.tmf-dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .4rem; }
.tmf-df-preview img { max-width: 100%; max-height: 12rem; display: block; margin: 0 auto; border: 1px solid #e6e2dd; }
.tmf-special-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(2.4rem, 1fr)); gap: 4px; margin-bottom: .6rem; max-height: 18rem; overflow-y: auto; }
.tmf-special-char { font: 1.05em/1 Georgia, "Latha", "Nirmala UI", serif; height: 2.4rem; border: 1px solid #d6d3cf; border-radius: 5px; background: #fff; cursor: pointer; }
.tmf-special-char:hover, .tmf-special-char:focus-visible { border-color: var(--tmf-accent); outline: none; background: #faf6f2; }
@media (max-width: 640px) {
  .tmf-tb-label { display: none; }
  .tmf-editor--full .tmf-editor-area { min-height: 18rem; padding: .8rem; }
}
.tmf-editor-source[hidden], .tmf-editor-area[hidden], .tmf-field textarea[hidden] { display: none !important; }
.tmf-tb-select { height: auto; min-height: 2rem; line-height: 1.3; padding: .25rem 1.6rem .25rem .45rem; }
/* Dialogs sit outside the form: give them the form's colours. */
.tmf-dialog { --tmf-accent: #6b2e1f; --tmf-border: #d6d3cf; --tmf-muted: #5f5a55; --tmf-bg: #fff; --tmf-soft: #faf7f4; font-size: 16px; line-height: 1.5; }
.tmf-dialog *, .tmf-dialog *::before, .tmf-dialog *::after { box-sizing: border-box; }
.tmf-dialog .tmf-submit { padding: .55rem 1.1rem; }
